Reputation: 7454
I see 2 syntax for define a directive in angular js.
The first way is :
angular.module("map-mcbjam", []);
angular.module("map-mcbjam", []).directive('map', function() { ...} )
The second way is :
angular.module("map-mcbjam", ['directives']);
angular.module('directives', []).directive('map', function() { ...} )
Can soemone know how to explain the differences between those 2 methods ?
Upvotes: 1
Views: 39
Reputation: 3783
The second way allows you to share the directive between several modules :
angular.module("map-mcbjam", ['directives']);
angular.module("map2-mcbjam2", ['directives']);
angular.module("map3-mcbjam3", ['directives']);
angular.module('directives', []).directive('map', function() { ...} )
If you think your directive may be useful outside the module map-mcbjam, you should use the second way so that you can reuse it.
Upvotes: 2