1
我有一個簡單的NG-重複:AngularJS NG-重複過濾項基於日期值
<li ng-repeat="data in myData.Entries">
{{ data.EntryNumber }} --
<strong>From</strong> {{ data.InfoDetails[0].FromDt.substring(6, data.InfoDetails[0].FromDt.length - 2) | date:'MMM yyyy' }} <strong>to</strong>
{{ data.InfoDetails[0].ToDt == null && 'current' || data.InfoDetails[0].ToDt.substring(6, data.InfoDetails[0].ToDt.length - 2) | date:'MMM yyyy'}}
</li>
該款顯示器(如預期):只包括
E1 -- From Nov 2011 to current
A1 -- From Jun 2010 to Nov 2011
X1 -- From Apr 2009 to Jun 2010
Z1 -- From Sep 2003 to Jun 2004
我可以過濾這些數據小於3歲的物品(從當年起)。
我的JS:
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.myData = {
"Entries": [{
"EntryNumber": "E1",
"InfoDetails": [{
"FromDt": "/Date(1320912000000)/",
"ToDt": null,
"RegisteredAs": {
"SurName": "test",
"Title": "MRS"
},
"RegisteredWith": "test"
}]
}, {
"EntryNumber": "A1",
"InfoDetails": [{
"FromDt": "/Date(1276153200000)/",
"ToDt": "/Date(1320912000000)/",
"RegisteredAs": {
"SurName": "test",
"Title": "MR"
},
"RegisteredWith": "test"
}]
}, {
"EntryNumber": "X1",
"InfoDetails": [{
"FromDt": "/Date(1239346800000)/",
"ToDt": "/Date(1276153200000)/",
"RegisteredAs": {
"SurName": "test",
"Title": "MR"
},
"RegisteredWith": "test"
}]
}, {
"EntryNumber": "Z1",
"InfoDetails": [{
"FromDt": "/Date(1063177200000)/",
"ToDt": "/Date(1086850800000)/",
"RegisteredAs": {
"SurName": "test",
"Title": "MR"
},
"RegisteredWith": "test"
}]
}
]
}
});
繼承人plunker:http://plnkr.co/edit/xscddt6AlhxUYIVIklQy?p=preview
@dhavlcengg - 感謝,但輸出列表處理不當更新? –
我比較過,應該是3歲。如果將其更改爲更大的值,則會在輸出列表中找到差異。 – dhavalcengg
這可以基於todt嗎? –