0

Im having trouble with a filter i have something like this:

<tr ng-repeat="data in dataset | filter:{id:12}">       
    <td>{{data.id}}</td>
    <td>{{data.name}}</td>
</tr>

i would to be able to filter by an array of ids something like this

id=[12,14,23]

and show the rows that have those ids

thanks for any help

4

1 回答 1

2
<tr ng-repeat="data in dataset | filter:filterFunction">       
    <td>{{data.id}}</td>
    <td>{{data.name}}</td>
</tr>

控制器:

$scope.filterFunction = function(data) {
  return $scope.filterValues.indexOf(data.id) !== -1 ? true : false;
};

$scope.filterValues = [12, 14, 23];
于 2013-07-24T22:23:47.897 回答