I have a problem with getting updated value between in different page controller, Here is the situation.
page1.html
<body ng-app="app">
<div ng-controller="ctrl1">{{ version }}</div>
</body>
page2.html
<body ng-app="app">
<div ng-controller="ctrl2">{{ version }}</div>
</body>
app.js
var app = angular.module("app", []);
app.run(function($rootScope) {
$rootScope.Data = [];
$rootScope.Data.Version = '1.0.0.1';
});
app.controller('ctrl1', function($scope, $rootScope){
$scope.version = $rootScope.Data.Version;
$rootScope.Data.Version = '1.0.0.2';
});
app.controller('ctrl2', function($scope, $rootScope){
$scope.version = $rootScope.Data.Version;
});
Result
version: 1.0.0.1 // page1.html
version: 1.0.0.1 // page2.html
Expected Result
version: 1.0.0.1 // page1.html
version: 1.0.0.2 // page2.html
How to achieve this kind situation?
I tried using $broadcast
from this tutorial for seprate page controllers: fiddle