Home » AngularJS ng-selected Directive

AngularJS ng-selected Directive

by Online Tutorials Library

AngularJS ng-selected Directive

The AngularJS ng-selected directive adds the selected attribute on the element, if it gets that the expression inside ng-selected is true.

The ng-selected directive is necessary to makes you able to shift the value between true and false. In HTML, the selected attribute cannot be set to false.

It is supported by <option> element.

Syntax:

Parameter explanation:

expression: It specifies an expression that will set the element’s selected attribute if it returns true.

Let’s take an example to demonstrate the usage of ng-selected directive.

See this example:

Test it Now

You may also like