Page 1 of 1

How to remove Lines in an Ionic Grid

Posted: Tue Mar 15, 2016 12:48 pm
by Pasteur Miranda

Hi,

Code: Select all

In the Ionic/AngularJs PizzaCreator example, you show how to insert a line in a grid when  choose an ingredient and click the "add" button. Suppose, now, the user wants to remove an ingredient from the grid. I tried this, inserting a "delete" button in the row, and a method deleteItem() attached to the burron's ng-click directive. To remove the ingredient, I know that first I have to remove it from the $scope.customList array using the "delete" operator:  delete $scope.customList[INDEX]. My question is: 

1)How to get the INDEX of the item to be deleted in the Grid? 
2) How to remove the deleted ingredient's line from the Grid? 

         Thank You.

How to remove Lines in an Ionic Grid

Posted: Tue Mar 15, 2016 1:48 pm
by Serhii Kulibaba

Hello,

You can get index of the current grid, if tou use track by $index: https://docs.angularjs.org/api/ng/dir...


How to remove Lines in an Ionic Grid

Posted: Wed Mar 16, 2016 5:46 pm
by Pasteur Miranda

Hi, Sergiy.

I got the index of the current grid row $ index: I created a scope function named deleteItem(row), that was called from the ng-click directive of the delete button, using the $index: ng-click=deleteItem($index). The deleteItem(row) function code is
delete $scope.customList[row]. It works, It removes the ingredient from the customList, but the grid row is not deleted, it remains there, blanked. I would like to know how to delete this blank grid row.

Code: Select all

 Thank You

How to remove Lines in an Ionic Grid

Posted: Wed Mar 16, 2016 9:03 pm
by Pasteur Miranda

Hi,
I solved just replacing $scope.customList[row] by $scope.customList.splice(row,1). Now, both array element and grid row are deleted.

Code: Select all

Thank you