0
我想在角控制器來過濾兩個表達式和兩個比較器功能我用循環代碼一個以上的表達和比較器工作正常
angular.forEach(vm.campaignData, function (value) {
if (value.startTime < today && value.endTime > today) {
vm.campaignFilteredData.push(value);
}
});
,但我想用$過濾器,但它不工作
vm.campaignFilteredData =$filter('filter')(vm.campaignData, {startTime : today , endTime: today} ,
function(actual, expected) { return actual < expected;},function(actual, expected) { return actual > expected;});
我的數據是這樣的
[{
"name": "Levis Marketing Event Vadodra Himalaya Mall",
"tenantId": 1,
"locationId": 5,
"createdByName": "sg_area_manager",
"startTime": 1462300200000,
"endTime": 1462473000000,
"description": "This event for Marketing Levis Vadodra Himalaya Mall",
"metricIds": [],
"comparisionStartTs": 0,
"comparisionEndTs": 0
},{
"name": "Levis Festival Event Vadodra Himalaya Mall",
"tenantId": 1,
"locationId": 5,
"createdByName": "sg_area_manager",
"startTime": 1462300200000,
"endTime": 1462473000000,
"description": "This event for Festival Levis Vadodra Himalaya Mall",
"metricIds": [],
"comparisionStartTs": 0,
"comparisionEndTs": 0
}]
你能重現與的jsfiddle或Plunker一些數據? –
您好@RomeshJain我的其他過濾器工作完美,像這樣==> vm.campaignFilteredData = $ filter('filter')(vm.campaignData,{startTime:today},function(actual,expected){return actual> expected;}) ; –
好的!但是,如果您提供數據並且哪些不起作用,這將會很有幫助。另外提一下,預計會有什麼結果。 –