4

AngularJs provides you the possibility to create modules. All fine. It also give you the power to add components to your modules like service, controller, etc...

My only problem with that is that no matter in what module did you define a component, from another module it can be entirely overwritten.

Examples:

app.module('aModule').controller('SimpleController', functino(){...});
app.module('bModule').controller('SimpleController', functino(){...});

If you try to define let's say a state definiction with ui-router, it will just won't work well, since one controller will completely overwrite the one loaded first.

Did you guys met with this problem too or it's just me?

1
  • 1
    nice question. Name space collision is a real problem for Angular 1 users. I am really curious in any efficient solution, other than "naming your components properly" ... Commented Jan 8, 2016 at 8:47

1 Answer 1

2

no, that's normal behavior. You can namespace it like 'component.controller' (so do this in the name of the controller, not the module) which helps, other then that is not possible in Angular 1

Sign up to request clarification or add additional context in comments.

4 Comments

nah, it won't help neither. It's just naming your modules but it won't have any affect on overwriting your controllers which has the same name.
he meant name controllers according the containing module.
I see, but I would not use this workaround. Would be a mess when trying injecting those services/values/etc..
fine, but that workaround is the only 'solution' as far as I know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.