Issue
Had generated one json array using the filter.
orders = filterFilter(vm.gridOptions.data, {
sampleId: 295
});
Here I filtered my orders array and I got this.
{
"orders": [
{
"orderId": 51491,
"orderDate": "2016-12-19T13:35:39",
"regId": 1354,
"sampleId": 295,
"name": "Test",
"nameAr": "Test"
},
{
"orderId": 51493,
"orderDate": "2016-12-19T13:35:39",
"regId": 1354,
"sampleId": 295,
"name": "Test",
"nameAr": "Test",
}
]
}
Can I filter in way, It should keep only one field in the orders array. Using angular filter I need to do this.
I need an array like this.
{
"orders": [
{
"orderId": 51491
},
{
"orderId": 51493
}
]
}
Solution
Alternatively, You can iterate through the orders
to generate the array of objects having orderIds
. Like this,
$scope.orderIDs = [];
angular.forEach($scope.orders, function(order){
$scope.orderIDs.push({
"orderId": order.orderId
})
});
Answered By - tanmay
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.