javascript - Angular filtering based on the field value -
i have table performing ng-repeat , getting data server
<tr ng-repeat="assetsdetail in detailassets | filter: {ind_record_type : !running}:true"> <td>{{assetsdetail.master_asset_type}}</td> <td>{{assetsdetail.minor_asset_type}}</td> <td>{{assetsdetail.detail_asset_type}}</td> <td>{{assetsdetail.product_desc}}</td> <td>{{assetsdetail.vendor_name}}</td> <td>{{assetsdetail.ind_record_type}}</td> </tr>
what want achieve here want data except 1 has ind_record_type of running. have far failed achieve this, simple way in view?
well, don't need filter that. simple ng-show can trick follows:
<tr ng-repeat="assetsdetail in detailassets" ng-hide="assetsdetail.ind_record_type == 'running'"> <td>{{assetsdetail.master_asset_type}}</td> <td>{{assetsdetail.minor_asset_type}}</td> <td>{{assetsdetail.detail_asset_type}}</td> <td>{{assetsdetail.product_desc}}</td> <td>{{assetsdetail.vendor_name}}</td> <td>{{assetsdetail.ind_record_type}}</td> </tr>
however, if adamant on using filter here's how can it:
<tr ng-repeat="assetsdetail in detailassets | filter: filteritem"> <td>{{assetsdetail.master_asset_type}}</td> <td>{{assetsdetail.minor_asset_type}}</td> <td>{{assetsdetail.detail_asset_type}}</td> <td>{{assetsdetail.product_desc}}</td> <td>{{assetsdetail.vendor_name}}</td> <td>{{assetsdetail.ind_record_type}}</td> </tr>
and in controller, declare function 'filteritem' follows:
$scope.filteritem = function(item) { if(item.ind_record_type == 'running') { return false; } return true; }
what function takes each 'item' of array , returns true if want display or false if want hide it. 'item' in case 'assetsdetail'
Comments
Post a Comment