102
AngularJS ng-required Directive
The AngularJS ng-required directive is used to add the required validator to ng-model. It is mainly used for input and select control but it can also be used for custom controls.
The ng-required directive is necessary to makes you able to shift the value between true and false. In HTML, the required attribute cannot be set to false.
It is supported by <input>, <select>, and <textarea> and other editable elements.
Syntax:
Parameter explanation:
expression: It specifies an expression that will set the required attribute if it returns true.
Let’s take an example to demonstrate the usage of ng-required directive.
See this example:
Next TopicAngularJS ng-selected Directive