ng-show不会重新评估路线变化

时间:2017-04-27 19:22:03

标签: angularjs

当用户从退出移动到登录时,我尝试在工具栏之间切换,但ng-show似乎没有在路线更改时重新评估。

这是我目前的代码

      <div ng-controller="MainController as vm" ng-show="vm.currentPath === '/'">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#/home">Home</a></li>
          <li><a href="#/about">About</a></li>
          <li><a href="#/signup">Sign up</a></li>
          <li><a href="#/login">Log in</a></li>
        </ul>
      </div>

      <div ng-controller="BuilderController as vm" ng-show="vm.currentPath === '/builder'">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#/home" ng-click="vm.logout()">Logout</a></li>
        </ul>
      </div>

在MainController和BuilderController中,我有:

var vm = this;
vm.currentPath = $location.path();

0 个答案:

没有答案