- Ngmodelcontroller method
It is called when the view needs to be updated. Instructions that use Ng-model should implement this method on their own.
This method is used to determine whether the input value is empty.
For example, a directive that uses ngmodelcontroller requires that the method be used when it is necessary to determine if there are any input values. This method can be used to determine whether the value is undefined, ', null, or Nan.
You can reload the method to suit your needs.
- $setValidity (Validationerrorkey, isValid);
This method is used to change the validation status and to notify the table when the validation criteria for changes are controlled.
This method should be called by a validator. For example, a parser or a format function.
This method is used to set control to the original state.
The method can remove the ' Ng-dirty ' class and restore control to its original state (' Ng-pristine ' Class).
- $setViewValue (value, Trigger) method
This method is used to update the view values. This method should be called when a view value has changed, typically in a DOM event handler function. For example, the input and select Directives Call this function.
This method will update the $viewvalue property and pass the value to each function in $pasers, which includes the validator. When this value is output from $parsers, it will be used for expressions in $modelvalue and Ng-model properties.
Finally, all listeners registered in the $viewchangelisteners list will be called.
- $cancelUpdate ();
This method is used to cancel an update and reset the value of the INPUT element to prevent $viewcalue from occurring, which is raised by a pending debounced event or because the input box waits for some future event.
Angularjs–ngmodelcontroller detailed