Reputation: 347
I am new the angular, what I am trying to do is applying filter on inner array of an object from table row, filter is working but works only for that td, not for the entire row, why is this happening, is there anything missing here? Any help is much appreciated.
plunker here: http://plnkr.co/edit/lXxTS1A3zRCk6mdtw2JP?p=preview
Upvotes: 1
Views: 529
Reputation: 422
Use a filter function to pipe a second filter to your Project list: http://plnkr.co/edit/ydKDEUUWZcI0Qt9fQxhB?p=preview
$scope.applyToTitle = function (title)
{
if($scope.support.code.length !== 0)
{
for(var i=0; i<$scope.tableObject.length; i++)
{
for(var j=0; j<$scope.tableObject[i].details.length; j++)
{
if(title.details[j].code == $scope.support.code)
{
return title;
}
}
}
}
else
{
return title;
}
}
And apply this filter by piping it after filter:search:
<tr ng-repeat="item in tableObject | filter:search | filter: applyToTitle">
<td>{{item.title}}</td>
...
Upvotes: 1
Reputation: 9998
You should apply the filter to the correct field where is associated your ng-model. So instead of:
<tr ng-repeat="item in tableObject | filter:search">
It should be for example:
<tr ng-repeat="item in tableObject | filter:search.title">
Upvotes: 0