Javascript AngularJS,oclazyload动态加载模块

Javascript AngularJS,oclazyload动态加载模块,javascript,angularjs,module,oclazyload,Javascript,Angularjs,Module,Oclazyload,我已经实现了在需要时加载模块的模块。所以我实现了获取状态和js文件的结构: --app --main (loader module) --views --controllers --services (global) --modules (custom modules) --authentification --view/controllers/services --a

我已经实现了在需要时加载模块的模块。所以我实现了获取状态和js文件的结构:

--app --main (loader module) --views --controllers --services (global) --modules (custom modules) --authentification --view/controllers/services --authentification.config.js (state list and dependecies) --users --view/controllers/services --users.config.js (state list and dependecies) --app.config.js (abstract global state) --global.modules.js (modules list to load when needed) --应用程序 --主(装载机模块) --观点 --控制器 --服务(全球) --模块(自定义模块) --认证 --视图/控制器/服务 --authentication.config.js(状态列表和依赖项) --使用者 --视图/控制器/服务 --users.config.js(状态列表和依赖项) --app.config.js(抽象全局状态) --global.modules.js(需要时加载的模块列表) 我的问题是: 当我重新加载页面时,它会将我重定向到其他url。所以我做了一个调查,发现AngularUI路由器在加载负责的模块之前读取url。我需要延迟获取URL,直到加载程序模块完成加载

global.modules.js

// Custom App Modules var CUSTOM_MODULES = [ { name: 'users', autoLoad: true }, { name: 'authentification', autoLoad: true } ]; //自定义应用程序模块 var自定义_模块=[ { 名称:'用户', 自动加载:正确 }, { 名称:“身份验证”, 自动加载:正确 } ]; authentication.config.js

ModuleFactory.createModule({ module : 'authentification', // Name of the module dependencies : ['WS'], // Dependency injection states : [ { name: 'user', url: '/user', abstract: false }, { name: 'user.login', url: '/login', templateUrl: 'login.html', services: ['authCas.js', 'authWS.js', 'profile.js'], controllers: ['loginController.js'] }, { name: 'user.forgetpassword', url: '/sendmailconfirmation', templateUrl: 'forgetpassword.html' } ] }); ModuleFactory.createModule({ 模块:'身份验证',//模块的名称 依赖项:['WS'],//依赖项注入 国家:[ { 名称:“用户”, url:“/user”, 摘要:错 }, { 名称:“user.login”, url:“/login”, templateUrl:'login.html', 服务:['authCas.js','authWS.js','profile.js'], 控制器:['loginController.js'] }, { 名称:“user.forgetpassword”, url:“/sendmailconfirmation”, templateUrl:'forgetpassword.html' } ] });
app.config.js
ModuleFactory.createModule({
模块:'应用',//模块名称
isBootstrapModule:true,
依赖项:['ui.router','ui.bootstrap','ui.load','ui.jq','ui.validate','oc.lazyLoad','oc.lazyLoad.config','ngDebug'],
otherwiseUrl:“/app/home”,
国家:[
{
名称:'应用',//状态名称
url:“/app”,//状态url
摘要:true,//如果您的状态只是一个布局/容器,则为true
供应商模块:供应商模块
},
{
名称:“app.home”,
url:“/home”,
templateUrl:'home.html',
控制器:['homeController.js']
}
]
});

您需要在状态解析回调上使用$ocLazyload。请详细解释此解决方案。查找解析:部分-您需要在状态解析回调上使用$ocLazyload。请详细解释此解决方案。查找解析:部分-
app.config.js
<pre>
ModuleFactory.createModule({
    module : 'app', // Name of the module
    isBootstrapModule : true,
    dependencies : [ 'ui.router','ui.bootstrap','ui.load','ui.jq','ui.validate',  'oc.lazyLoad', 'oc.lazyload.config', 'ngDebug'],
    otherwiseUrl : '/app/home',
    states : [
        {
            name: 'app', // State Name
            url: '/app', // State URL
            abstract: true, // true if your state is just a layout / container
            vendorModules: VENDOR_MODULES
        },
        {
            name: 'app.home',
            url: '/home',
            templateUrl: 'home.html',
            controllers: ['homeController.js']
        }
    ]
});