how to run more than one angular directive modules on Pprod

我是研究僧i 提交于 2019-12-04 13:26:32

问题


I am working on jhipster Release 0.7.0 and I have multiple type of directive modules in our jhipster app.first for index page and second for commmon directive.

When we run on Prod profile i got an exception :-

[31mPhantomJS 1.9.7 (Windows 7) ERROR[39m Error: [$injector:nomod] Module 'common-services' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.2.11-build.2192+sha.e2173f9/$injector/nomod?p0=common-services at D:/github_repo/gather-our-code/src/main/webapp/bower_components/angular/angular.js:1531

same code is working on develop profile ..

Please help me to solve this bug ASAP


回答1:


The "prod" profile uses JavaScript minification (run by Grunt), which will reduce the size of your JavaScript file. As this modifies your JavaScript code, it can cause issues, depending on how you write your dependency injection code. Have you looked at the sample directives that are provided ? Or at the sample controllers ? You must write your dependency injection in the same style.

For example, to inject the $scope:

jhipsterApp.controller('MainController', ['$scope',
    function ($scope) {
}]);

This will ensure the minification process won't break dependency injection of the "$scope" variable.

If you can't make it work, you can also exclude your files from the minification process: it depends on your load, but for most applications this is overkill. This is configured in your Gruntfile.js file.



来源:https://stackoverflow.com/questions/21726619/how-to-run-more-than-one-angular-directive-modules-on-pprod

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