AngularJS延迟加载路由无法正常工作

时间:2018-11-16 11:14:49

标签: angularjs routing

有人可以帮助我进行此路由吗?它总是会出现以下错误:

  

未捕获的错误:[$ injector:modulerr]

相关代码:

var app = angular.module('mainApp', ['ui.router', 'oc.lazyLoad','ngRoute', 'commonApp', 'adminApp', 'ui.bootstrap', 'gm', 'ngMessages', 'daterangepicker','customDirectives', 'mw-datepicker-range','uiGmapgoogle-maps','ngAutocomplete','ngImageCompress']);

app.config(['$ocLazyLoadProvider', '$stateProvider', '$urlRouterProvider','uiGmapGoogleMapApiProvider' , function($ocLazyLoadProvider, $stateProvider, $urlRouterProvider,uiGmapGoogleMapApiProvider) {
$urlRouterProvider.otherwise("/home");

//Config For ocLazyLoading
$ocLazyLoadProvider.config({
    'debug': true, // For debugging 'true/false'
    'events': true, // For Event 'true/false'
    'modules': [{ // Set modules initially
        name : 'home', // State1 module
        files: ['home/home.controller.js',
                'home/home.service.js',
                'home/homeMapper.service.js',

                ]
    },{
        name : 'about', // State2 module
        files: ['about/about.controller.js']
    }]
});

//Config/states of UI Router
$stateProvider
.state('home', {
    url: "/home",
    views : {
        "" : {
            templateUrl:"/home/home.html"
        }
    },
    resolve: {
        loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
            return $ocLazyLoad.load('home'); // Resolve promise and load before view 
        }]
    }
})
.state('about', {
    url: "/about",
    views : {
        "" : {
            templateUrl:"/about/about.html"
        }
    },
    resolve: {
        loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
            return $ocLazyLoad.load('about'); // Resolve promise and load before view 
        }]
    }
  });
}]);

0 个答案:

没有答案