0

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.

1
  • Would help if you replicate this in a plunkr or fiddle. Commented Nov 21, 2014 at 20:54

1 Answer 1

2

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 }}
Sign up to request clarification or add additional context in comments.

2 Comments

This is really strange... I double-checked everything again. Should be fine. I mean, I am getting the users in the drop down menu anyway, so there should be no problem while retrieving them from the controller. It is just the fact, that I cannot make a preselection :/
This answer should not be a comment ;)

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.