angularjs - What is the proper module/directive/filter/etc syntax in angular? -
i've seen modules, , directives, filters, etc defined in modules, written different ways , curious if there benefit 1 on other.
for example, have module defining directive in looks this:
var app = angular.module('app', []); app.directive('mydirective', function() { return { restrict: 'e', template: '<a href="http://google.com">google</a>' } });
but see written following lot, directive definition inside the module:
angular.module('app', []) .directive('mydirective', function() { return { restrict: 'e', template: '<a href="http://google.com">google</a>' } });
which way better? thanks!
it's same.
module(name,dependencies)
returns module defined.the difference between 2 in first exemple put module variable.which in exemple 1 unnecessary.
but see written following lot, directive definition inside the module:
it's not inside module,you calling method of module,directive,factory... methods of module.
it's called method chaining.
Comments
Post a Comment