What are Directives in Angular Js? Explain important directives.
Question :
What are Directives in Angular Js? Explain important directives.
AngularJS directives are used to extend HTML. Directives are markers on HTML DOM element that tell AngularJS to attach a specified behavior to that HTML element.
Directives in AngularJS are special attributes starting with ng- prefix where ng stands for Angular. AngularJS includes various built-in directives, you may also create your own directive in AngularJS. Some built-in directives are listed here.
ng-app
The ng-app directive defines the root element of an AngularJS application and starts an AngularJS Application.The ng-app directive will auto-bootstrap (automatically initialize) the application when a web page is loaded. It is also used to load various AngularJS modules in AngularJS Application.
ng-init
ng-init directive initializes an AngularJS Application data. It is used to declare and assign values to the variables for an AngularJS application.
ng-repeat
The ng-repeat directive repeats HTML elements for each item in a collection. Or simply say that it is used to loop through items in collection element and it will act as for loop.
ng-model
The ng-model directive is used for two-way data binding in AngularJS. It is used to get value of input controls like textbox, label, etc and use these values in web pages.
ng-bind
The ng-bind directive binds the model property declared via ng-model directive or the result of
an expression to the HTML element. It also updates an element if the value of an expression
changes.