[英]Reload page with $route in Angular JS
I've built a login module using Angular JS. 我已经使用Angular JS构建了一个登录模块。 After all validation and database checks have been made using $http, if the login is successful, the page needs to reload so the PHP can show the correct content to the user.
使用$ http完成所有验证和数据库检查之后,如果登录成功,则需要重新加载页面,以便PHP可以向用户显示正确的内容。
I've tried using $route to reload the page, but I just get weird errors like 我试过使用$ route重新加载页面,但是我只收到奇怪的错误,例如
Error: [$injector:unpr]....
Relevant code: 相关代码:
(function(){
var app = angular.module('login',[]);
app.controller('LoginController', function($scope,$http,$route){
$scope.loginCheck = function(){
$http({
method : 'POST',
data : $.param($scope.login),
url : '/assets/includes/login.php?query=login',
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(data){
if (data == 'success') $route.reload();
});
};
});
})();
Why don't you just do a hard refresh, you want to re-render the server page if I'm not mistaken, a plain old Javascript reload should do it: location.reload();
您为什么不做一次硬刷新,如果我没记错的话,您想重新渲染服务器页面,一个普通的旧Javascript重载就可以做到:
location.reload();
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.