javascript - How to inject / load Angular directive in an app -
my main.js
in root folder of app.
-app |_ routes.js |_ main.js -components |_directives |_abc-directive.js
how define directive can added folder.
i tried this:
abc-directive.js
:
var abcdirective = function() { // directive code }
main.js
:
app.main = angular.module('main', ['ngroute', 'components.directives']); app.main.directive('abcdirective', "<i don't want define directive here, rather load diff. folder>");
you can define controllers, directives in own modules , add modules dependency main module
abc-directive.js
var app = angular.module('directives.abcdirective', []) app.directive('abcdirective', ...
main.js
var app = angular.module('mainapp', ['directives.abcdirective'])
you can use requirejs manage dependencies..
Comments
Post a Comment