我有這個數組:如何過濾對象數組?
$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和結束日期爲空的所有對象。
過濾後的結果:
$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
使用過濾功能?