Injector:modulerr in the config (newbie)
Injector:modulerr in the config (newbie)
我有如下所示的应用程序配置,当我使用方法>函数重定向$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"可以互换。
相关文章:
- What does requirejs.config() do?
- 创建了一个选项卡,但点击时不会起作用-jQuery issue/newbie
- 从Middleman中的Javascript访问config.rb
- 使用AddThis-config-data_ga_property向两个Google Analytics配置文件报告
- JS vs JSON for config in Node js
- Web.config: Values for ClientValidationEnabled and Unobtrusi
- EmberJS config prod img src url
- 在Require.js中,如果Require()是一个函数,那么Require.config()是如何存在的
- 在Asp.net的空网站中,如何改变"Web.config”;使内容(.js)文件显示在浏览器中,而不是下载
- RequireJS Config映射整个目录
- 我没有'我不了解require.js是如何处理加载路径的.每次定义模块时是否需要使用require.config
- django-ckeditor:存储config.js的位置
- AngularJs在app.config中的回调中配置路由
- 通过特定的Web.Config目录提供URL重写
- log4javascript web.config
- Angular.config未被调用
- 如何在OrientDb-server-config.xml中启用CORS
- 重构 require.config.js 文件
- config routeProvidar on angularJS
- Injector:modulerr in the config (newbie)