Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if i work with multiple modules ? #51

Open
belarfaoui-zakaria opened this issue Jan 23, 2016 · 2 comments
Open

What if i work with multiple modules ? #51

belarfaoui-zakaria opened this issue Jan 23, 2016 · 2 comments

Comments

@belarfaoui-zakaria
Copy link

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')

@CaryLandholt
Copy link
Owner

Hi @belarfaoui-zakaria,

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

Before and after code would be great.

Thanks,
Cary

@matt328
Copy link

matt328 commented Apr 15, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants