This is th json, this need to be filtered based on the "testType" equal to 'R' also had to sort based on "createdDate"
{
"code": null,
"message": "Total 1 records found",
"result": {
"size": 0,
"dob": 412977600000,
"sex": "F",
"visitMasts": [
{
"createdBy": 61,
"visitId": 1235,
"ordersList": [
{
"testId": 4,
"ordersDto": {
"orderId": 50815,
"testType": "R",
"createdDate": 1479277029456
}
},
{
"testId": 4,
"ordersDto": {
"orderId": 50807,
"testType": "R",
"createdDate": 1479016014784
}
}
]
}
]
}
}
The filtering is achieved using this,
vm user = response.data.result;
if (vm.user.visitMasts[0].ordersList != null && vm.user.visitMasts[0].ordersList.length > 0) {
radioTestDetails = filterFilter(vm.user.visitMasts[0].ordersList, {
ordersDto: {
testType: 'R'
}
});
}
How can I sort the value based on this
response.data.result in that visitMasts -> orderList[] -> createdDate
(vm.user.visitMasts[0].ordersList.sort(function(l,r){return l.createdDate - r.createdDate})
$filter('orderBy')(radioTestDetails, 'ordersDto. createdDate')
to reverse order, just add a third parameter set to true:$filter('orderBy')(radioTestDetails, 'ordersDto. createdDate', true)
l.createdDate
tol.ordersDto.createdDate
. Like thisvm.user.visitMasts[0].ordersList.sort(function(l,r){return l.ordersDto.createdDate - r.ordersDto.createdDate}