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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -