how to do $filter with more then one expression and comparator in angularjs -
i want filter in angular controller 2 expression , 2 comparator function code loop working fine
angular.foreach(vm.campaigndata, function (value) { if (value.starttime < today && value.endtime > today) { vm.campaignfiltereddata.push(value); } });
but want $filter not working
vm.campaignfiltereddata =$filter('filter')(vm.campaigndata, {starttime : today , endtime: today} , function(actual, expected ) { return actual < expected;},function(actual, expected ) { return actual > expected;});
my data this
[{
"name": "levis marketing event vadodra himalaya mall", "tenantid": 1, "locationid": 5, "createdbyname": "sg_area_manager", "starttime": 1462300200000, "endtime": 1462473000000, "description": "this event 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 festival levis vadodra himalaya mall", "metricids": [], "comparisionstartts": 0, "comparisionendts": 0
}]
not ideal solution, gets job done. better create own angular filter though.
https://jsfiddle.net/ygl8rnb8/
vm.campaignfiltereddata = $filter('filter')(vm.campaigndata, function(value) { if (value.starttime < today && value.endtime > today) { return true; } } );
Comments
Post a Comment