Collateral naming in AngularJS definitions

I'm currently trying to organize my Angular application so that it scales appropriately at the enterprise level. However, I find that there seems to be an over reliance on naming conventions within the framework, and trying to avoid name collisions is a real problem.

For example, when defining any constants / controllers / directives / factories / filters / providers / services , a name is specified that is implicitly used during dependency injection.

This works fine with multiple definitions. However, when there may be hundreds (perhaps thousands) of these definitions, trying to manage and prevent duplicates seems a bit of a maintenance nightmare!

Another problem is directive naming. Since there seems to be no way to apply any context to directives, it is impossible to have something like the following (that is, reuse the name "button"):

 <toolbar> <button></button> </toolbar> <customform> <button></button> </customform> 

Therefore, we rely on verbose naming conventions again. If you include the recommended provider prefix, you will get something like this:

 <company:toolbar> <company:toolbar-button></company:toolbar-button> </company:toolbar> <company:customform> <company:customform-button></company:customform-button> </company:customform> 

I admit that this is not terrible, but he emphasizes how dependency on naming conventions can easily cause conflicts.

Is there anything on the Angular roadmap to solve the namespace problem, and what would be the current (1.0.6) recommended solution to the problem?

+6
source share
1 answer

I don’t think there is a solution for this now. This is definitely a problem when your applications get larger or when you have to include arbitrary modules that may not be known at dev-time. I would recommend submitting a question for this using the angular project.

0
source

All Articles