在.run

时间:2016-09-14 08:56:34

标签: angularjs angular-ui-router angular-services

我在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}。我如何获得当前状态?

0 个答案:

没有答案