1

I have a select box:

<body ng-controller="MainCtrl">
  <form>
    <select ng-model="aSelect"
      ng-options="i for i in range">
    </select>  
  </form>
</body>

The range is specified in the controller as [1,2,3]. How do I set one of these values as the selected value? Plunker can be found here: http://plnkr.co/edit/2HjvYVEqkslGNSsErXr2?p=preview

Any thoughts greatly appreciated

C

1 Answer 1

4

Use ngInit:

<select ng-init="aSelect = 1" ng-model="aSelect" ng-options="i for i in range">
</select>
Sign up to request clarification or add additional context in comments.

1 Comment

how does this work when the first item in the range is not 1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.