×

Html & Html5

The World's best Software Development Study Portal

AngularJS Directives


AngularJS has a set of built-in directives
or AngularJS also lets you define your own directives.
AngularJS directives are extended HTML attributes with the prefix ng-
like

ng-app directive defines the root element

ng-init directive defines initial values

ng-model directive binds the value of HTML controls

ng-repeat directive actually clones HTML elements,used on an array of objects




New directives are created by using the .directive function.
When naming a directive, you must use a camel case name, w3TestDirective but when invoking it, you must use - separated name, w3-test-directive


You can restrict your directives to only be invoked by some of the methods.
By adding a restrict property with the value "A", the directive can only be invoked by attributes: