alonisser alonisser - 1 year ago 75
AngularJS Question

Angularjs - separating directive files, but staying on the same module

I'm trying to separate a directive to another file, without having to declare a new module - not doing:


but just :


the myapp.directives module exists in another file and works fine. but when I try to use it in another file as shown above (without
) it fails.

following this answer It believe my approach should work, but for some reason it fails..

Answer Source

WHen you first declare a module it needs to have the dependency argument. Afterwards you can refrence that same module using only the module name argument.

/* create module */

/* declare components of same module, note same name*/

If you want to create new modules, you need to inject them in the main ng-app module as dependencies

/* main ng-app module , injects another module you created below*/

/* new module, must have dependency argument */
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download