I have multiple select box for user to select his roles.
<select ng-options="role.name for role in roles"
ng-model="user.roles"
multiple="multiple">
</select>
"roles" - is the list of roles that user can select
[{"id":1,"name":"Moderator"},{"id":2,"name":"Admin"}]
"user.roles" - list of roles that user actually have
{"id":5,"email":"[email protected]","roles":[{"id":2,"name":"Admin"}]}
Both "roles" and "user" are loading dynamically via ajax. The problem is that when I load user that already have roles - they are not automatically selected in the select box. How do I select them?