0

I have the following objects and properties:

User - TitleID
     - FirstName
     - Surname
     - EmailAddress

Titles - CodeID
       - Description

The user's title should be preselected in a select element which also contains all the other Titles from the Titles.

Although I can get all the titles to display in the select box, I cannot get it to pre-select the correct (or indeed any) title from the select box when editing a user.

This is what I have so far:

<select ng-model="user.TitleID" ng-options="title.CodeID as title.Description for title in titles track by title.CodeID">

How do I go about getting the correct title preselected with this relational data?

1 Answer 1

2

There's a potential bug in Angular where track by and as don't work together in ngOptions.

GitHub Issue #6564

Remove the track by and it'll work...

JsFiddle

Sign up to request clarification or add additional context in comments.

Comments

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.