使用angularjs重定向到相同的URL SAN查询参数
我加载用于密码重置的应用程序URL,如下所示: 成功重置后,我想重定向到同一页面上的登录组件,但URL应为: 我尝试使用使用angularjs重定向到相同的URL SAN查询参数,angularjs,routing,query-string,Angularjs,Routing,Query String,我加载用于密码重置的应用程序URL,如下所示: 成功重置后,我想重定向到同一页面上的登录组件,但URL应为: 我尝试使用$window.location.reload()和$location.path('/my/path').search({})但这不起作用。它仍然显示带有查询字符串的url vm.resetpassword = function () { $scope.errorMessage = ''; var changePasswordModel
$window.location.reload()
和$location.path('/my/path').search({})代码>但这不起作用。它仍然显示带有查询字符串的url
vm.resetpassword = function () {
$scope.errorMessage = '';
var changePasswordModel = new SetPasswordModel();
changePasswordModel.resetcode = $route.current.params.resetcode;
changePasswordModel.newpassword = vm.password;
changePasswordModel.confirmpassword = vm.retypepassword;
if (vm.password.length >= 8 && common.isPasswordValid(vm.password))
{
security.resetPassword(changePasswordModel)
.then(function () {
$scope.message = "Updating Password...";
$timeout(function () {
$location.search({});
}, 3000);
}, function (err) {
$scope.errorMessage = err.ModelState.Error[0];
});
} else {
$scope.showPasswordPolicy = true;
}
};
解决方案:
var url = $location.search({});
window.location.href = url.absUrl();
要删除URL参数,请使用
$location.url($location.path());
或者您可以简单地使用它来删除所有参数
$location.search({});
试试这个
window.location.href="your path";
它不起作用。我为重置功能添加了代码。它不起作用。我添加了重置函数的代码。事实上,这可能有效-但当我将路径指定为window.location.href=$location.path()时,它会重定向到localhost/login,但它应该是localhost/myapp/#/login而不是$location.path(),直接将路径指定为myapp/login/…html尝试使用它可能有效..var url=$location.search({});window.location.href=url.absUrl();