My current data object structure looks like this :
$scope.data = [
{
"name": "1001",
"queue": [
{
"number": "111",
}
]
},
{
"name": "1002",
"queue": [
]
},
{
"name": "1008",
"queue": [
{
"number": "222",
}
]
}]
In my AngularJS project, I have initialized 3 empty arrays:
$scope.a = [];
$scope.b = [];
$scope.c = [];
The desired outcome that I am aiming for :
If I were to execute console.log($scope.a);
, the expected output would be :
{
"name": "1001",
"queue": [
{
"number": "111",
}
]
}
If I were to execute console.log($scope.b);
, the expected output should be :
{
"name": "1008",
"queue": [
{
"number": "222",
}
]
}
And if I were to execute console.log($scope.c);
, then the anticipated result should be :
{
"name": "1002",
"queue": [
]
}
I am seeking a way to iterate through the data and based on the values in the queue array, push objects into different arrays. Specifically, I want to push objects with queue number "111" into $scope.a, objects with queue number "222" into $scope.b, and objects with an empty queue array into $scope.c. I am currently stuck on how to filter these objects by examining the values within the queue array. Can someone guide me on how to achieve this in AngularJS?