VOOZH about

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

⇱ AngularJS | ng-selected Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS | ng-selected Directive

Last Updated : 1 Aug, 2024

The ng-selected Directive in AngularJS is used to specify the selected attribute of an HTML element. It can be used to select the default value specified on an HTML element. If the expression inside the ng-selected directive returns true then the selected option value will be displayed otherwise not displayed. 

Syntax:

<element ng-selected="expression">
Contents...
</element>

Parameter value:

  • expression: It is used for setting the element's selected attribute if it returns true.

Example: This example uses the ng-selected Directive to display the selected element. 

Output:

Example 2: This example describes the use of the ng-selected Directive in AngularJS by disabling the checkbox & ng-selected option.

Output:

Comment

Explore