Thursday, June 29, 2017

ng-model in AngularJS

Models in Angular.JS are represented by the "ng-model" directive. The primary purpose of this directive is to bind the "view" to the "model".

The ng-model attribute is used for,

  • Binding controls such as input, text area and select in the view into the model. 
  • Provide a validation behavior - for example a validation can be added to a textbox that only numeric characters can be entered into the textbox. 
  • The ng-model attribute maintains the state of the control (By state, we mean that the control and the data is bound to be always kept in sync. If the value of our data changes , it will automatically change the value in the control and vice versa)

No comments:

Post a Comment