我在Angular Service中有这段代码
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams, options) {
if (storageService.getValue("login_credentials") && (storageService.getValue("auto_login"))) {
httpService.doLogin(function (){
if (!toState.data.require_authentication) {
return 0;
}
if (!checkStorageIntegrity(toState.data)) {
event.preventDefault();
$state.go("page.login");
return;
}
validate(function (data) {
if (!data.fn.result.done) {
$state.go("page.login");
}
storageService.setKey("auto_login", false);
});
});
}
但我想在.run中移动httpService.doLogin({....})而我没有tostate。如果我使用$ state.current给我{name: "", url: "^", views: null, abstract: true}
。我如何获得当前状态?