0

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 ?

7
  • use ng-model on select and bind to something like selectedMember in scope Commented Jul 9, 2014 at 17:03
  • I have described my current approach in the edited post, but I am not satisfied with it. Commented Jul 9, 2014 at 17:09
  • "current selected object from the table" - how do you select something from the table? Are you trying to set the object.member_id for all members based on the <select> changing? What you describe you want is confusing Commented Jul 9, 2014 at 17:15
  • Well that is what I was trying to avoid. I only want to set the object.member_id of only one 'object' object based on the <select> Commented Jul 9, 2014 at 17:17
  • the 'setCurrentSelectObject' method gets me the current selected object, sorry for being ambiguous Commented Jul 9, 2014 at 17:18

0

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.