I have entries, their json object looks somewhat like this
{
'id': 5,
'activityId': 1
}
then I have activities, their json object looks like this
{
'id': 1,
'name': 'Activity name',
'rate': 1200
}
now I'm rendering entries like this
<tr ng-repeat="entry in entries">
<td>
<activities></activities>
</td>
<td>
// here's supposed to be the rate
</td>
</tr>
where activities is a directive that looks like this
app.directive("activities", function() {
return {
restrict: 'E',
template: '<select ng-model="entry.activityId" ng-options="a.id as a.name for a in activities"></select>'
}
});
now what would I need to do, to be able to print the rate inside my ng-repeat? Since it's an attribute of something that's inside the directive, but I need it printed outside the directive.
Thanks..
You could use:
{{(activities | filter:{id: entry.activityId})[0].rate}}
though I find this a bit ugly. A better way would be to add the activity directly as a property of your entities, maybe after loading both data-sets. Another way would be a self-made filter that also checks for errors (e.g. activityId not found, etc.).