Utilizing AngularJS, my application contains two controllers that share a common service. When triggering an event controlled by the portalController
function (specifically the setLang()
function), I notice that the model of the applicationController does not update.
This issue seems to be specific to Firefox and Chrome, as it works unexpectedly fine in IE8.
PortalController
(function () {
'use strict';
var controllers = angular.module('portal.controllers');
controllers.controller('portalController', function portalController($scope, UserService, NavigationService, $translate) {
$scope.User = UserService.getUserinfo();
$scope.setLang = function (langKey) {
$translate.uses(langKey);
UserService.setUserinfoLocale(langKey);
UserService.getUserApplications(Constants.key_ESS);
UserService.getUserApplications(Constants.key_MED);
UserService.getUserApplications(Constants.key_SVF);
$.removeCookie(Constants.cookie_locale);
var domain = document.domain;
if (domain.indexOf(Constants.context_acc) != -1 || domain.indexOf(Constants.context_prd) != -1 || domain.indexOf(Constants.context_tst) != -1) {
domain = "." + domain;
$.cookie(Constants.cookie_locale, langKey, {path:"/", domain:domain});
} else {
$.cookie(Constants.cookie_locale, langKey, {path:"/"});
}
};
$scope.logout = function () {
NavigationService.logout();
};
$translate.uses(UserService.getUserinfoLocale());
});
//mainController.$inject = ['$scope','UserInfo'];
}());
ApplicationController
(function () {
'use strict';
var controllers = angular.module('portal.controllers');
controllers.controller('applicationController', function ($scope, UserService) {
$scope.ESS = UserService.getUserApplications(Constants.key_ESS);
$scope.SVF = UserService.getUserApplications(Constants.key_SVF);
$scope.MED = UserService.getUserApplications(Constants.key_MED);
});
}());
The shared UserService
UserService.prototype.getUserApplications = function(entity){
var locale = this.getUserinfoLocale();
return this.userApplications.query({locale: locale, entity: entity});
};