I've defined some models in App.run
below which I'm overriding within the controller someCtrl
:
App.run(['$rootScope', function($rootScope) {
$rootScope.attempt = 1;
});
function someCtrl($scope, $rootScope) {
$rootScope.attempt = 2;
$rootScope.checkAttempt = function () {
return $rootScope.attempt > 1 ? true : false;
};
}
There is a button on the page out of someCtrl's
scope:
<button class='btn' ng-disabled="checkAttempt()">Who's changing my value?</button>
FYI, I'm aware of creating a service or using emit-broadcaste mechanism to share data across controllers but I would like to know How authenticate is it to inject $rootScope into a controller?