![]() |
VOOZH | about |
The ng-required Directive in AngularJS is used to specify the required attribute of an HTML element. The input field in the form is required only if the expression inside the ng-required directive returns true. It is supported by <input>, <select> and <textarea> tags.
Syntax:
<element ng-required="expression"> Contents... </element>
Example 1: This example uses the ng-required Directive to set the input text field of the form tag to required.
Output:
Example 2: This example uses the ng-required Directive to create the required field after checking the checkbox.
Output: