以下是我的Route Configuraion
function configFunc($routeProvider)
{
$routeProvider.when("/", { templateUrl: "partials/staffhome.html" });
$routeProvider.when("/stafflist", { templateUrl: "partials/stafflist.html", });
$routeProvider.when("/staffform/:staffId?", { templateUrl: "partials/staffform.html", controller:"StaffFormCtrl"});
}
我在 / staffform 中有一个登录表单,成功时应该重定向到 / stafflist 。
onLoginSuccess = function (auth) {
$scope.errormessage = "";
//clear loginform
$scope.email = "";
$scope.password = "";
$scope.authEmail = auth.email;
window.location = "#/stafflist";
}
这导致Watchers在最后5次迭代中被解雇:[]。
如果我注释掉window.location重定向行,则不会触发观察者。