Injector:modulerr in the config (newbie)

Injector:modulerr in the config (newbie)

本文关键字:newbie config the modulerr in Injector      更新时间:2023-09-26

我有如下所示的应用程序配置,当我使用方法>函数重定向$q时$injector,我得到 Injector:modulerr 错误,当注释该函数块时,应用程序运行良好。如果我在这个配置块代码中遗漏了任何内容,请帮助我。我是 angularjs 的新手,希望你能帮助我。

app.config([ '$stateProvider', '$urlRouterProvider','$authProvider', '$controllerProvider',  '$httpProvider', '$compileProvider', '$filterProvider', '$provide', '$ocLazyLoadProvider', 'JS_REQUIRES',
function ($stateProvider, $urlRouterProvider, $authProvider, $controllerProvider, $compileProvider, $httpProvider, $filterProvider, $provide, $ocLazyLoadProvider, jsRequires) {
app.controller = $controllerProvider.register;
app.directive = $compileProvider.directive;
app.filter = $filterProvider.register;
app.factory = $provide.factory;
app.service = $provide.service;
app.constant = $provide.constant;
app.value = $provide.value;
$ocLazyLoadProvider.config({
    debug: false,
    events: true,
    modules: jsRequires.modules
});
function redirectWhenLoggedOut($q, $injector) {
    return {
        responseError: function(rejection) {
            // Need to use $injector.get to bring in $state or else we get
            // a circular dependency error
            var $state = $injector.get('$state');
            // Instead of checking for a status code of 400 which might be used
            // for other reasons in Laravel, we check for the specific rejection
            // reasons to tell us if we need to redirect to the login state
            var rejectionReasons = ['token_not_provided', 'token_expired', 'token_absent', 'token_invalid'];
            // Loop through each rejection reason and redirect to the login
            // state if one is encountered
            angular.forEach(rejectionReasons, function(value, key) {
                if(rejection.data.error === value) {
                    // If we get a rejection corresponding to one of the reasons
                    // in our array, we know we need to authenticate the user so 
                    // we can remove the current user from local storage
                    localStorage.removeItem('user');
                    // Send the user to the auth state so they can login
                    $state.go('login.signin');
                }
            });
            return $q.reject(rejection);
        }
    }
}
// Setup for the $httpInterceptor
$provide.factory('redirectWhenLoggedOut', redirectWhenLoggedOut);
// Push the new factory onto the $http interceptor array
$httpProvider.interceptors.push('redirectWhenLoggedOut');
$authProvider.loginUrl = 'http://localhost/himalayan-engineering-college/public/api/authenticate';
// APPLICATION ROUTES
// -----------------------------------
// For any unmatched url, redirect to /app/dashboard
$urlRouterProvider.otherwise("/login/signin");
//
// Set up the states
$stateProvider.state('app', {
        url: "/app",
        templateUrl: "assets/views/app.html",
        resolve: loadSequence('modernizr', 'moment', 'angularMoment', 'uiSwitch', 'perfect-scrollbar-plugin', 'perfect_scrollbar', 'toaster', 'ngAside', 'vAccordion', 'sweet-alert', 'chartjs', 'tc.chartjs', 'oitozero.ngSweetAlert','satellizer','AuthController'),
        abstract: true
    }).state('app.dashboard', {
        url: "/dashboard",
        templateUrl: "assets/views/dashboard.html",
        resolve: loadSequence('satellizer','jquery-sparkline', 'dashboardCtrl','chartsCtrl'),
        title: 'Dashboard',
        ncyBreadcrumb: {
            label: 'Dashboard'
        }
    })....//more states
}]);

你能尝试纠正函数中依赖关系的顺序吗?"$httpProvider"、"$compileProvider"可以互换。