AngularJS ng-required Directive
Definition and Usage
ng-required
The ng-required directive sets the form field (input or text area) to required
attribute.
if ng-required
the expression returned in the attribute true
then the form field will be required.
ng-required
Instructions are necessary for toggling values between true and false. In HTML, you cannot set the required attribute to false (the presence of the required attribute makes the element a required field regardless of its value).
Example
Set the input field to required:
Required:
<input type="checkbox" ng-model="myVar"> <input name="myInput" ng-model="myInput" ng-required="myVar">
Syntax
<input ng-required="expression</input>
Affected <input>
,<select>
and <textarea>
and other editable elements supported.
Parameters
Parameters | Description |
---|---|
expression | If it returns true, the expression that sets the required attribute will be set. |