Open In App

AngularJS Directives Complete Reference

Last Updated : 29 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Directives are markers in the Document Object Model(DOM). Directives can be used with any of controller or HTML tag which will tell the compiler what exact operation or behavior is expected. There are some directives present which is predefined but if a developer wants he can create new directives (custom-directive).

Example: This example uses ng-app Directive to define a default AngularJS application.




<html>        
<head> 
    <title>AngularJS Directives</title> 
    <script src= 
    </script> 
</head> 
<body style="text-align:center"
           
    <h2 style = "color:green">Geeksforgeeks</h2> 
    <div ng-app="" ng-init="name='GeeksforGeeks'"
        <p>{{ name }} is the portal for geeks.</p>
    </div> 
</body>   
</html> 


Output:

The following table lists the important built-in AngularJS directives.

Directives Description
ng-app Start of AngularJS application.
ng-init Used to initialise a variable
ng-model ng-model is used to bind to the HTML controls
ng-controller Attaches a controller to the view
ng-bind Binds the value with HTML element
ng-repeat Repeats HTML template once per each item in the specified collection.
ng-show Shows or hides the associated HTML element
ng-readonly Makes HTML element read-only
ng-disabled Use to disable or enable a button dynamically
ng-if Removes or recreates HTML element
ng-click Custom step on click

Directives:

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads