I have table and a select control:
<table>
<tr ng-repeat="object in objects" ng-click="setCurrentSelectObject(object)">
<td>{{object.id}}</td>
<td>{{object.member_id}}</td>
<td>{{object.description}}</td>
</tr>
</table>
<select ng-options="m for m in members" ></select>
members
and objects
are some arrays that are loaded using $resource
by AngularJS.
object.member_id
is a foreign key value to members.id
, I want to bind object.member_id
with the selected member.id
in the select control.
How do I do that ?
Edit: My approach until now:
I use ng-model=selectedMember
inside the select
control, and that gives me a member array, which is a complex structure from which I only need member.id
and on-change="changedMember"
.
Inside changeMember
I have the current selected object from the table to which I do : currentObject.member_id = selectedMember
.
But this is a workaround, isn 't there a more ng-model-ish way of doing this ?
ng-model
on select and bind to something likeselectedMember
in scopeobject.member_id
for allmembers
based on the<select>
changing? What you describe you want is confusing