There is a login button in navbarControl. Click login to open a login box with $uibModel. The controller is loginCtrl. How to pass the value from this loginCtrl to navbarControl?
.factory('data',function(){
var myData = {loginInfo:true};
return {
myMenu : function(){
return myData;
}
}
})
navabarControl中
$scope.unlogin = data.myMenu.loginInfo;
loginCtrl中
$scope.login = function(){
//登录操作
data.myMenu.loginInfo = true;
}
The current question is, how to detect the change in the value of data.myMenu.loginInfo in navbarControll. I changed the value of data.myMenu.loginInfo when logging in, but the value of navabarControll is still the original assignment
You can add a
service
,service
是全局单例。两个controller
通过service
shared data