AngularJS – ngSelected Directive

AngularJSWeb DevelopmentFront End Technology

The ngSelected Directive in AngularJS sets the selected attribute element on the element to True. We can also write an expression inside the ngSelected with the only condition that it should evaluate to True.

This special directive is necessary since interpolation cannot be used inside the selected attribute.


<element ng-required="expression">..content..</element>

Example − ngSelected Directive

Create a file "ngSelected.html" in your Angular project directory and copy-paste the following code snippet.

<!DOCTYPE html>
      <title>ngSelected Directive</title>

      <script src="">

   <body ng-app style="text-align: center;">
      <h1 style="color: green;">
         Welcome to Tutorials Point
         AngularJS | ngSelected Directive
      <label>Check me to select: <input type="checkbox" ng-model="selected" /></label><br />
      <select aria-label="ngSelected demo">
         <option id="greet" ng-selected="selected">Welcome to Tutorials Point!</option>


To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Updated on 08-Oct-2021 11:59:25