AngularJS

AngularJS Directives

AngularJS Filters and Elements

AngularJS Tutorials

AngularJS Directives

AngularJS Directives

 

 

AngularJS directives are the extension of HTML attributes by using ng-. 

 

The main used directives are:-

 

  • The ng-init directive is used to initialize.
  • The ng-app directive defines an AngularJS application. It also tells that the current element is the owner of the application.
  • The ng-model directive binds the value of HTML controls.
  • The ng-bind directive binds application data to the HTML view.
  • The ng-repeat directive is used to repeat. It is used on arrays of objects

 

ng-app Directive

 

The ng-app directive is used to define the root element. It will be automatically initialized when the web page is loaded.

 

Syntax:-

 

< element ng-app="module_name" >

// AngularJS Code goes here

< /element >

 

Further Explanation:-

 

Value Description
module_name Optional. Defines the name of a module to load with the application

 

ng-init Directive

 

The ng-init directive is used to define the initial values for the application.

 

Syntax:-

 

< element ng-init="expression" >< /element >

 

Further Explanation:-

 

Value Description
expression An expression to evaluate.

 

ng-model Directive

 

The ng-model directive is used to bind with HTML Controls. It can also be used for type validation, status for the applicatiion.

 

Syntax:-

 

< element ng-model="name" >< /element >

 

Further Explanation:-

 

Value Description
name The name of the property you want to bind to the form field.

Code Explanation

All Tutorials related to AngularJS Tutorials

All Sections related to AngularJS