[英]Page keep reloading after redirecting in Angular 1.5
In my app I need to redirect users who are not authorised to enter certain routes. 在我的应用中,我需要重定向无权输入某些路由的用户。 Here is part of my code: 这是我的代码的一部分:
$http.post(apiURL + '/all' , {
token: localStorage.getItem('token')
}).success(function (data) {
$rootScope.roomPictures = data;
}).error(function (error, status) {
if (status === 401) {
window.location.href = 'auth.html';
}
});
The angular actually redirects to auth.html, but then browser keeps refreshing and refreshing. 角度实际上重定向到auth.html,但随后浏览器不断刷新。 What am I doing wrong here? 我在这里做错了什么?
So the problem was that in auth.html I had the same controller as I had in the current .html file. 因此问题在于,在auth.html中,我具有与当前.html文件中相同的控制器。 After creating new controller and adding it to the auth.html file everything works as it should. 创建新的控制器并将其添加到auth.html文件后,一切都会正常进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.