I have this piece of code:
<tr ng-repeat="row in someController.searchResults"
ng-class="{'selected': tableRow.selected}"
ng-click="selectRow(tableRow)" >
In this piece of code I'm iterating through searchResults
array.
I need to add a condition (want to do it with ngIf).
someController.searchResults
someController.someOtherSearchResults
How can I achieve that?
You can use plain javascript in the ng-repeat
attribute, like so:
<tr ng-repeat="row in (someController.importantBoolean ? someController.searchResults : someController.someOtherSearchResults)"
ng-class="{'selected': row.selected}"
ng-click="selectRow(row)" >
</tr>
See the following plunker for an example: https://plnkr.co/edit/Nxh9gVB9GDP5FaLVDGrS