angular.js - webpack require.ensure asynchronous loading of angular module problem
过去多啦不再A梦
过去多啦不再A梦 2017-05-15 16:58:48
0
1
705

An error is reported when hot loading the login.controller.js below,

If you remove resolve and import './login.controller' directly at the top, no error will be reported. What is the reason for this?

#login.route.js 文件require.ensure打包加载
import LoginTpl from './login.tpl.html';

var LoginRoute = {
    template    :   LoginTpl,
    controller  :   'LoginCtrl',
    resolve: {
        loadModule : ['$q','$ocLazyLoad',function ($q,$ocLazyLoad) {
            return $q((resolve) => {
                require.ensure([], () => {
                    let module = require('./login.controller');
                    $ocLazyLoad.load({name: 'cm.bg.login'});
                    resolve(module);
                });
            });
        }]
    }
};
export default LoginRoute;

#login.controller.js 热加载的模块

import './login.module'
import '../../../service/LoginService' //登入服务

export default angular.module('cm.bg.login')
    .controller('LoginCtrl',['Login',function(LoginService){
                
    }])
    

Is it related to the order in which they are packaged? Packaged out, 104 is the loginService and 103 is under the contorller. If so, how to change it?

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
Peter_Zhu

Try webpack’s plugin : order occurrence

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template