VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-required-directive/

⇱ AngularJS ng-required Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-required Directive

Last Updated : 11 Jul, 2025

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:

👁 Image
 

 Example 2: This example uses the ng-required Directive to create the required field after checking the checkbox. 

Output:

👁 Image
 
Comment

Explore