Mik378 Mik378 - 1 year ago 110
AngularJS Question

Handling files order regarding concatenation with WebPack?

A good practice when using Angular is to separate module definition from each usage of this module (one usage per file).

For instance:

angular.module('home', []);

.service('HomeService', HomeService);

Classic issue is regarding files concatenation:

is injected before
in the final file, this would result in this error:

Uncaught Error: [$injector:modulerr]

Using gulp, there's a handy gulp-angular-sort that could manage it for us.

How to handle Angular files ordering when dealing with WebPack and files concatenation, to prevent this kind of disorder?

Answer Source

I disagree, this line .service('HomeService', HomeService); belongs to module, not service. So you have following setup:


export default ['$timeout', ..., ($timeout, ...) => { /*some code*/}]


import HomeService from 'HomeService.service.js'

angular.module('home', [])
 .service('HomeService', HomeService);

You do not have any problems with order in this case.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download