angular.js - Value passing problem during angularjs control
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-15 17:10:44
0
1
481

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

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
巴扎黑

You can add a service,service是全局单例。两个controller通过serviceshared data

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template