3

Code:

<select ng-model="ticket.owner.id" 
        ng-options="user.id as getFullName(user) for user in users" required>
</select>

The above example actually works. However when I send the modified object to my rest api, the only changed value of the object is the ID. E.g. when option 1 is selected and I select option2 and submit, the object associated to option1 is send, but with the ID of option2.

When I have:

<select ng-model="ticket.owner" 
        ng-options="user as getFullName(user) for user in users" required>
</select>

and change the selected value and submit, the correct object is transmitted to rest api. However the select box is broken, it shows an empty field and does not set the selected value.

Any ideas we can use the select box to select objects but not just ID's?

1 Answer 1

4

Not sure your implementation of getFullName() and what is actually getting sent to the rest service.

http://plnkr.co/edit/U7WIe4CvPUQFJFE4NtB6?p=preview

You can see in this example, ticket.owner being one of the object in users array that is chosen by the select box. And selection box shows the full name of the users.

Is this what you want?

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

3 Comments

Exactly this is what I already have. How can I remove the empty option field?
You can simply put the initial value for the ticket.owner. I updated the plnkr. See: stackoverflow.com/a/12654812/1238847
that plnkr isn't working, would have been really helpful for me to see it :(

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.