我想知道如果数组中的属性为空,我如何过滤数组以仅显示结果。我尝试过以下但无济于事:
<tr ng-repeat="performanceOrder in performanceOrders | filter: salesId.length === 0">
如果salesId
为空,我只想显示结果,这可能吗?
salesId
是performanceOrder
performanceOrder: {
salesId: "S273626",
status: "Open",
...
}
答案 0 :(得分:1)
使用ngShow:
<tr ng-show="!salesId.length" ng-repeat="performanceOrder in performanceOrders">
使用ngIf:
<tr ng-if="!salesId.length" ng-repeat="performanceOrder in performanceOrders">
答案 1 :(得分:0)
你可以在过滤器中使用这样的函数:
<tr ng-repeat="performanceOrder in performanceOrders | filter: myFilter()>
然后,在相应的控制器中,您可以执行以下操作:
$scope.myFilter = function (val) {
return val.salesId.length === 0;
}