I am using angular.bootstrap() to initialize my app. I want to assign some values to my $rootScope after this. I am trying this but it is not working for me:
var app = angular.module('myApp', []);
var modulesToLoad = ['myApp'];
angular.bootstrap(b, modulesToLoad);
app.run(function($rootScope) {
$rootScope.isLoading = false;
}
The bootstrap function returns the $injector
, so you could do something like this:
var app = angular.module('myApp', []);
var modulesToLoad = ['myApp'];
var injector = angular.bootstrap(b, modulesToLoad);
injector.invoke(function($rootScope) {
$rootScope.isLoading = false;
});
<body>
{{globalText}}
<div ng-controller="MyCtrl">
{{localText}}
</div>
var myModule = angular.module('app2', []);
myModule.value('globalText', 'GLOBAL');
myModule.run(function($rootScope, globalText) {
$rootScope.globalText = globalText;
});
myModule.controller('MyCtrl', function($scope) {
$scope.localText = 'LOCAL';
});