[英]Page redirection not working in angularjs using window.location.href
我正在编码一个页面,在该页面中,用户在输入字段中输入了数据之后,将使用ajax请求来验证数据。 验证数据之后,必须将页面重定向到另一个页面。
下面的代码不起作用:
$scope.validateUser = function() {
username = $scope.username;
password = $scope.password;
if ( username === "nrvarun89") {
console.log(username+" "+password+" path is :"+window.location.href);
window.location.href = "http://localhost/b2c-webadmin/index/";
console.log(username+" "+password+" new path is :"+window.location);
}
};
如果您使用的是anuglarjs,请使用$ window服务(最佳做法):
https://docs.angularjs.org/api/ng/service/ $ window
这应该工作:
$window.location.href
(请参阅此作为参考: https : //docs.angularjs.org/guide/ $ location)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.