startupModule.js:
(function () {
'use strict';
let app = angular.module('startupModule', []);
app.controller('controller1', function () {
// do this work on loading...
});
app.controller('controller2', function () {
// do this work on loading...
});
}());
loginModule.js:
(function () {
'use strict';
let app = angular.module('loginModule', []);
app.controller('loginController', function () {
});
}());
In the view:
<div ng-app="startupModule" ng-controller="controller1">
</div>
<div ng-app="loginModule" ng-controller="loginController">
</div>
<div ng-app="startupModule" ng-controller="controller2">
</div>
On loading, I want to call controllers controller1 and controller2 to do some works automatically. loginModule is the main module that I want to use and it cannot be removed or combined with startupModule.
When I run it, there was no error in Console. But the controller controller2 in the third div cannot be excuted, because ng-app="startupModule" cannot be recalled (I guess).
To check again, I've removed ng-app="startupController" ng-controller="controller1" in the first div. Then, controller2 should work.
My question: how can I call a module via calling ng-app multiple times?