In my application I have two modules, which are used for routing. Here is the code of it
//Module1:
angular.module('phonecat', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/phones', {templateUrl: 'partials/phone-list.html', controller: PhoneListCtrl}).
when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}).
otherwise({redirectTo: '/phones'});
}]);
Module2:
angular.module("computer",[]).config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/test',{templateUrl:'mypath/my-list.html',controller:ComputerListCtrl});
}]);
As per angularJS document, I have to register these modules into ng-app, like this
<html lang="en" ng-app="phonecat">
But in the above code, at a time I can register only one module, that is, phoneCat moudle or computer module. Because of this, I am able load only one module data into the application.
So please guide me, how can I register both the module into ng-app, during bootsrap or is there any other way I can do this.
You can create a top level module that will have your two modules as injected dependencies:
var app = angular.module('app', ['phonecat', 'computer']);
and then in your html use:ng-app="app"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With