您的位置:首页 > Web前端 > AngularJS

angularJs-----$filter过滤器使用 自定义过滤器

2017-12-19 19:55 537 查看

angularJs—–$filter过滤器使用 自定义过滤器

HTML

<table class="table table-striped table-border  ">
<tbody>
<tr>
<th style="width: 60px;text-align: center;">编号</th>
<th>农药名称</th>
<th>包装规格</th>
<th>销售价</th>
<th>分类名称</th>
<th>生产企业</th>
<th>状态</th>
<th>操作</th>
</tr>
<tr ng-repeat="item in pesticideList | filtrate">
<td ng-bind="$index+1">1</td>
<td ng-bind="item.pesticideRegName">农药名称</td>
<td><span ng-bind="item.packQuantity">100</span> <span> <span ng-bind="item.packStandard"></span>/   <span ng-bind="item.packUnit"></span></span></td>
<td><span ng-bind="item.sellPrice">0.00</span><span>元/ <span ng-bind="item.packUnit"></span></span></td>
<td ng-bind="item.classify">肥料</td>
<td ng-bind="item.produceCompany">浙江宜葆农科技术有限公司</td>
<td class="th-green" ng-bind="item.status == 0 ? '正常' : '停用'" ng-class="item.status == 0 ? 'th-green' : 'th-red'">正常</td>
<td style="cursor: pointer;"><span class="th-blue">编辑 </span><span class="th-blue"> | </span><span class="th-blue"> 删除 </span><span class="th-blue"> | </span><span class="th-blue"> 停用 </span></td>
</tr>
</tbody>
</table>


controller js

app.filter('filtrate', function() {
return function (arr) {
var array = [];
if( arr instanceof Array){
for(var i=0; i<arr.length ;i++){
if(arr[i].status == 0){
array.push(arr[i]);
}
}
}
return array;
}
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: