角加载条错误

时间:2015-09-17 11:03:59

标签: angularjs

我的角度加载条出错了

            var _responseError = function (rejection) {
            $http = $http || $injector.get('$http');
            var authData = localStorageService.get('authorizationData');
            var authService = $injector.get('authService');

            if (rejection.status === 401 && authData && authData.isActive == 'true') {
                var deferred = $q.defer(); // defer until we can re-request a new token
                var data = "grant_type=refresh_token&refresh_token=" + authData.refreshToken + "&client_id=" + authData.clientId;
                var baseAddress = $injector.get('baseAddress');
                var dateFormat = "YYYY-MM-DD HH:mm:ss";

                // Get a new token... (cannot inject $http directly as will cause a circular ref)
                $injector.get("$http")
                    .post(baseAddress + 'login', data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
                    .then(function (loginResponse) {
                        if (loginResponse.data) {
                            localStorageService.set('authorizationData',
                             {
                                 token: loginResponse.data.access_token,
                                 tokenExpire: loginResponse.data['.expires'],
                                 refreshToken: loginResponse.data.refresh_token,
                                 refreshTokenExpire: loginResponse.data.refreshTokenExpire,
                                 userName: authData.userName,
                                 roleName: loginResponse.data.roleName,
                                 isUserAdmin: loginResponse.data.isUserAdmin,
                                 clientId: 'Self',
                                 isActive: loginResponse.data.isActive
                             });
                            // now let's retry the original request 
                            $injector.get("$http")(rejection.config).then(function (response) {
                                // we have a successful response - resolve it using deferred
                                deferred.resolve(response);
                            }, function (response) {
                                deferred.reject(); // something went wrong
                            });
                        }
                        else {
                            deferred.reject(); // login call didn't give us data
                        }
                    },
                    function (response) {
                        // token retry failed, redirect so user can login again
                        deferred.reject(rejection);
                        if (!authInterceptorServiceFactory.isPopup) {
                            authInterceptorServiceFactory.isPopup = true;
                            var hr = moment.utc(moment(new Date()).diff(moment(new Date(authData.refreshTokenExpire)))).format("H");
                            var strHr = hr == 1 ? ' hour' : ' hours';

                            var min = moment.utc(moment(new Date()).diff(moment(new Date(authData.refreshTokenExpire)))).format("m");
                            if (min == 0) {
                                min = 1;
                            }

                            var strMin = min == 1 ? ' minute' : ' minutes';

                            var loginInfo = {
                                userName: authData.userName,
                                password: '',
                                expiryTime: moment.utc(moment(new Date()).diff(moment(new Date(authData.refreshTokenExpire)))).format("HH:mm:ss")
                            };

                            var ngDialog = $injector.get('ngDialog');
                            ngDialog.openConfirm({
                                template: '/app/account/loginDialog.html',
                                className: 'ngdialog-theme-default',
                                controller: 'loginDialogController',
                                showClose: false,
                                data: loginInfo
                            }).then(function (value) {
                                authInterceptorServiceFactory.isPopup = false;
                                //only refresh if GET request was executed
                                if (rejection.config.method == "GET")
                                    $window.location.reload();
                            }, function (reason) {
                                authInterceptorServiceFactory.isPopup = false;
                                // User has decided to logout from login modal so clear all
                                //authentication information, reject the request and redirect to login
                                blockUI.stop();
                                authService.logOut();
                                $location.path('/login');
                                return;
                            });
                        }
                    });

                return deferred.promise; // return the deferred promise
            }
            else if ((rejection.status === 401 && !authData) || (rejection.status === 401 && authData.isActive == 'false')) {

                    blockUI.stop();
                    authService.logOut();
                    $location.path('/login');
            }
            else if (rejection.status === 403) {
                // Unauthorized =  Access Forbidden 403 
                // Before navigating away, we need to clear the change tracker changes, otherwise the changes alert will appear.
                blockUI.stop();
                changeTrackerService.clearAllScopeChanges();
                $location.path('/unauthorized');

            }
            return $q.reject(rejection); // **I am getting error here** 
        }

,错误是

TypeError:无法读取undefined的属性'config'     出错(https://localhost:44303/Scripts/angular-block-ui.js?v=1.3:176:26)     在https://localhost:44303/Scripts/angular.min.js?v=1.3:109:276     at h.c. $ get.h. $ eval(https://localhost:44303/Scripts/angular.min.js?v=1.3:123:139)     at h.c. $ get.h. $ digest(https://localhost:44303/Scripts/angular.min.js?v=1.3:120:220)     at h.c. $ get.h. $ apply(https://localhost:44303/Scripts/angular.min.js?v=1.3:123:406)     在p(https://localhost:44303/Scripts/angular.min.js?v=1.3:80:284)     在J(https://localhost:44303/Scripts/angular.min.js?v=1.3:84:338)     在XMLHttpRequest.t.onload(https://localhost:44303/Scripts/angular.min.js?v=1.3:85:367)undefined(匿名函数)@ angular.min.js?v = 1.3:101b。$ get @ angular.min.js?v = 1.3:75(匿名函数)@ angular-block-ui.js?v = 1.3:19(匿名函数)@ angular.min.js?v = 1.3:109c。$ get.h. $ eval @ angular.min.js?v = 1.3:123c。 $ get.h. $ digest @ angular.min.js?v = 1.3:120c。$ get.h. $ apply @ angular.min.js?v = 1.3:123p @ angular.min.js?v = 1.3: 80J @ angular.min.js?v = 1.3:84t.onload @ angular.min.js?v = 1.3:85

angular.min.js?v = 1.3:101 TypeError:无法读取undefined属性'ignoreLoadingBar'     at config.responseError(https://localhost:44303/Scripts/loading-bar.js?v=1.3:129:32)     在https://localhost:44303/Scripts/angular.min.js?v=1.3:109:276     at h.c. $ get.h. $ eval(https://localhost:44303/Scripts/angular.min.js?v=1.3:123:139)     at h.c. $ get.h. $ digest(https://localhost:44303/Scripts/angular.min.js?v=1.3:120:220)     at h.c. $ get.h. $ apply(https://localhost:44303/Scripts/angular.min.js?v=1.3:123:406)     在p(https://localhost:44303/Scripts/angular.min.js?v=1.3:80:284)     在J(https://localhost:44303/Scripts/angular.min.js?v=1.3:84:338)     在XMLHttpRequest.t.onload(https://localhost:44303/Scripts/angular.min.js?v=1.3:85:367)undefined

1 个答案:

答案 0 :(得分:0)

不要使用Min进行开发

您在索引页面中需要做的第一件事是更改您正在使用的Angular版本。

发件人

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>

使用min非常适合生产,因为它更小,并且可以更快地进行互操作,但它具有非常误导性的错误。

切换到完整的Angular后,您会在编辑中发布新错误,我会添加到此答案中。