top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to delete array from a group of array in Angular JS?

+1 vote
463 views

I have a group of array in $scope.firstorder. For example:

enter image description here

Based on some condition like array contains an element Quantity. If Qunatity is zero i need to remove this array from the list of arrays.

How can I do that?

 for (index in $scope.firstorder)
    {
        var quantity = $scope.firstorder[index][0].Quantity;
        if (quantity == 0)
        {
            Remove the array element from $scope.firstOrder;
        } 


    }
posted Jun 9, 2017 by Shweta Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
$scope.firstorder = $scope.firstorder.filter(outerList=>{ 
      return outerList.filter(innerList=>{ 
          return innerList.Quantity === 0;
        }).length === 0; 
    });

You can use filter property to filter out the array..something as shown in the above code.

answer Jun 12, 2017 by Rohini Agarwal
...