mr.pribesh
mr.pribesh

Reputation: 187

AngularJS access data model from another data model

I am trying to pull data from one model in a single controller from another model on the same controller. I realize this is wrong but here is I am trying to do in the template:

<table class="list-group">
    <tr class="list-group-item" ng-repeat="info in field.infos">
        <td><span class="badge">{{info.due| date:short}}<span ng-repeat="member in info.idMembers">{{members[{{member}}]}}</span></span>
        </td>
        <td>{{info.name}}</td>
    </tr>
</table>

So the each field.info has a reference to a member by it's id. I want to pull the member's name from the members model based on the id but not sure how to do so. Any help would be greatly appreciated. Please let me know if I am not being clear.

Upvotes: 1

Views: 133

Answers (1)

Josh
Josh

Reputation: 44916

You don't need the double evaluation here:

{{members[{{member}}]}}

If member is indeed just an id, then you can do this:

{{members[member]}}

If however, member is an object, with some id property on it, then you might need to do this:

{{members[member.id]}}

Upvotes: 1

Related Questions