Reputation: 531
i am trying to filter my table data based on the input text, but some how it's not working. Kindly help please.
<div class="panel panel-default">
<div class="panel-heading">search
<input type="text" ng-model="search_text">
Searching for :: {{search_text}}
</div>
<Table>
<table class="table table-hover table-bordered">
<tr>
<td>Item ID</td>
<td>Quantity</td>
</tr>
<tr ng-repeat="item in items | filter:search_text">
<td>{{item.item[0] }}</td>
<td>{{item.item[1] }}</td>
</tr>
</table>
</div>
Upvotes: 1
Views: 1656
Reputation: 1333
Since Angular 1.1.3 you can use:
<tr ng-repeat="item in items | filter:{item[0]: search_text}">
This will compare it to the object property item[0] in your object. If you want the exact match, you can set the filtering to true by adding:
<tr ng-repeat="item in items | filter:{item[0]: search_text}:true">
Upvotes: 0
Reputation: 7425
Please check for the version your angularjs you are using or any errors in console.
Your code seems to work and is correct indeed.
//array of items containing itemID and its quantity
$scope.items = [{
item:['chair',45]
},
{
item:['bed',23]
},
{
item:['laptop',8]
}]
Here's the working plunkr
The table data is indeed filtering with respect to value you enter in textbox
Upvotes: 1