ng-classify icon indicating copy to clipboard operation
ng-classify copied to clipboard

What if i work with multiple modules ?

Open belarfaoui-zakaria opened this issue 9 years ago • 2 comments

Thank you for ng-classify, really useful extends a controller or a service for exemple, will generate only one module name but in my case i am working on multiple modules, and it will be useful if you develop the configuration/options side, so then we can define a prefix for every module name

best regards.

Exemple:

App.controller => angular.module('app') Dashboard.controller => angular.module('dashboard')

belarfaoui-zakaria avatar Jan 23 '16 17:01 belarfaoui-zakaria

Hi @belarfaoui-zakaria,

Can you clarify your request? I'm not quite following.

Before and after code would be great.

Thanks, Cary

CaryLandholt avatar Jan 24 '16 05:01 CaryLandholt

I just stumbled onto this myself and I think what @belarfaoui-zakaria may mean is when you pass a string to the class you are extending, that module has to have already been defined somewhere. ng-classify will generate angular.module('myModuleName').config... and with just that, if that module doesn't exist, you'll get errors. (With Angular 1.5.3, anyway). In this case, the correct syntax needs to be angular.module('myModuleName', []).config... where you pass the array of dependencies as the second argument, which for right now, seems to define the module and return it. I'm not sure how that will behave though in the case the module already does exist, would it trash that module's dependencies, or does it append any new ones?

A workaround I have found is that when you know you are using ng-classify to create a 'one-off' module, you can define the module like this angular.module 'moduleName', [] above your class definition.

I find I do this a lot as its an easy way to swap in interceptors, decorators, etc by just changing the main module's dependency list instead of having to add a build flag to conditionally include the files in the build.

matt328 avatar Apr 15 '16 14:04 matt328