Webpack Uglify causes routing to stop work

北慕城南 提交于 2019-11-30 16:39:54

You're using the latest version of ui-router, which has a newer and slightly different way of handling the resolve block. It takes an object map.

Try this:

    resolve: {
       foo: ['$q', '$ocLazyLoad', function($q, $ocLazyLoad) {
                var deferred = $q.defer();

                require.ensure([], function() {
                    var mod = require('./organizationStructure.module.js');
                    $ocLazyLoad.load({
                        name: 'app.organizationStructure'
                    });
                    deferred.resolve(mod.controller);
                });

                return deferred.promise;
       }]
    }  

Here is the ui-router API doc for this: https://github.com/angular-ui/ui-router/wiki#resolve

Pankaj Parkar

While doing minification you should for array annotation of DI.

You are not using angular di array notation inside you app.js, you need to do below changes.

From

app.config(routeConfig);

To

app.config(['$stateProvider', routeConfig]);

For more Information Refer this SO Answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!