I'm a bit at a loss here. I have an array of teammembers. Each teammember has a roleId. I also have an array of roles. Each role has an id. I loop over the teammembers and, for each teammember, I display their name and a select with all roles. That works fine. I am unable to have the current teammember's role preselected in the select.
This is my data struct:
teamMembers = [
{id,100,name:John,roleId,19},
{id,101,name:Sue,roleId,20},
...
]
roles = [
{id:19,name:'Administrator'},
{id:20,name:'Superuser'},
...
]
html:
<tr ng-repeat="teamMember in data.team.MEMBERS">
<td>
{{teamMember.firstName}} {{teamMember.infix}} {{teamMember.lastName}}</td>
<td>
<select
ng-model="teamMember.roleId"
ng-options="role.systemName for role in data.roles track by role.id">
</select>
</td>
What I want is that initially the select displays the role where teamMember.roleId == role.id. Also, the 2 way databinding should update the teamMembr.roleId such that it always equals the currently selected role.id.
Is it possible to do this in Angular 1.5.0? If so, how?
Thank you for any tips!