Reputation: 1081
I cannot figure out why the initial selection is not working in this code. Everything else is just fine. The options are all there, etc...
<select id="userEmail" class="form-control"
data-ng-init="userSelection = users[0]"
data-ng-model="userSelection"
data-ng-options="user.email for user in users">
</select>
Also the variant with userSelection = userSelection || users[0]
does not work.
Upvotes: 0
Views: 71
Reputation: 666
Would make this just a comment, but can't yet.
Your code should work. I pretty copied it into this plnkr and it works just fine.
I guess just make sure you have all your controllers and whatnots set up correctly.
<select id="userEmail" class="form-control"
data-ng-init="userSelection = users[5]"
data-ng-model="userSelection"
data-ng-options="user.email for user in users">
</select>
<hr>
{{ userSelection }}
Upvotes: 2