top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

+1 vote
37 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...