Angularjs-----Create Custom Directives ***attentive points***(Part I)

When creating custom directives, we can use ng-app module or create new modules.

1. Using existing ng-app module:

angular.module('app').directive....

2. Creating a new module:

var appNew = angular.module("app.newModule", []);
appNew.directive("newDirective"...)

 Pay atttention that in this situation(situation 2) we need to inject the new module into the ng-app module as dependencies.

var app = angular.module('app', ['app.newModule']);

 

BTW, when reference the js files, your main module js(eg:app.js) must precede all of his children (controller.js and directives.js).

posted @ 2016-07-12 17:12  滚烫的冰块  阅读(148)  评论(0)    收藏  举报