Reputation: 2033
I have a JSON object which is a parsed representation of a CSV file. I wanted to display it in a tabular format, so I used ng-repeat
twice:
<table class="table left">
<tbody>
<tr ng-repeat="invoice in invoices track by $index">
<td ng-repeat="data in invoice track by $index">
<div class="cell" ng-class="{ 'no-dealer': !isDealer(data) }">{{ data }}</div>
</td>
</tr>
</tbody>
</table>
This gets me what I want. However, now based on a specific value (which is a unique code) in the JSON objects, I want to apply the no-dealer
class on that specific tr/td (doesn't matter). How can I acheive this.
The data is like this
Upvotes: 3
Views: 63
Reputation: 1001
ng-repeat create a new scope, so for using the functions from parent scope you will have to use it like this -
ng-class="{ 'no-dealer': !$parent.$parent.isDealer(data) }"
Two times $parent to reach the main scope of page
Upvotes: 1