【发布时间】:2016-01-04 17:48:22
【问题描述】:
问题: 我有一个简单的注册表。新用户进行身份验证后,我的应用程序将他带到一个新链接,但不显示包含内容的新页面,也不在视图中切换 ng-if。所以视图没有刷新(但是当我按下 F5 按钮时一切都很好),我试图刷新它,但实际上并不了解我需要运行什么
注册表:
- 服务
Authentication。将数据设置为localStorage并转移到新链接的方法:
Authentication.registration = function(data) {
localStorage.setItem('registrationData', JSON.stringify(data));
$location.path('/userPage');
}
Authentication.ifLog = function() {
// verify if the user exists in localStorage
}
- 弹出登录表单,它是
Link函数中的directive(有自己的作用域)方法:
$scope.registration = function(form) {
Authentication.registration(
};
- 这一切都是为了切换菜单和转移到用户页面。当用户登录时,我们向他显示第一个和第三个菜单并将他转移到一个新页面。
'
Base' - 这是一个控制器,我从Authentication服务调用ifLog方法
<li ng-if="Base.logined"><a href="#userPage">UserPage</a></li>
<li ng-if="!Base.logined" ng-click="Base.toggleModal()">LogIn</li>
<li ng-if="Base.logined">{{Base.user.name}}</li>
我应该怎么做才能更新视图?
【问题讨论】:
标签: angularjs