The question might seem strange. But I like to organize my app in folder with directives being in a 'directives' folder, controller in a 'controllers' folder, etc....
In all the examples I've seen, directives are declared like that:
var app = angular.module('myModule').
directives('myDirective', function(){
});
What I want, is to declare myDirective in a separate file (which should not know about the app variable. Then when I create myModule, I'd like to assign it myDirective.
How do I do that ?
The way I do this is to create a module of directives and then inject that into my app:
Directive
angular.module('app.directives', []).directive(...).directive(...)
App
angular.module('myApp',['app.directives'])
You can do the same for services, filters, etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With