Question

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

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top