我有这个数组:
$scope.damageEvants =
[
{"id":2, "StartDate":21/05/2012, EndDate:null},
{"id":3, "StartDate":null, EndDate:02/09/2014},
{"id":4, "StartDate":null, EndDate:null},
{"id":5, "StartDate":21/05/2012, EndDate:null}
];
我想从属性startDate和EndDate为null的数组中过滤(删除)所有对象。
过滤后的结果:
$scope.damageEvants =
[
{"id":2, "StartDate":21/05/2012, EndDate:null},
{"id":3, "StartDate":null, EndDate:02/09/2014},
{"id":5, "StartDate":21/05/2012, EndDate:null}
];
我尝试了这个:
$scope.damageEvants.filter(return item.StartDate!== null && item.EndDate !== null )
但这似乎是错误的方式。
如何$scope.damageEvants
使用过滤功能进行过滤?
$scope.damageEvants.filter(return item.StartDate!== null && item.EndDate !== null )
应该是
$scope.damageEvants.filter(function(item) {
return item.StartDate!== null && item.EndDate !== null;
});
这 filter
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句