The task is to delete the item from the list when the button is clicked. This all should be done by using ng-click. This is done by using the splice() method. The syntax for the method is given below.
Syntax for splice() function:
array.splice(indexno, noofitems(n), item-1, item-2, ..., item-n)
Example for splice() function:
The keywords in syntax are explained here:
- indexno: This is required quantity. Definition is integer that specifies at what position to add/remove items.
If it is negative means to specify the position from the end of the array.
- noofitems(n): This is optional quantity. This indicates a number of items to be removed. If it is set to 0, no items will be removed.
- item-1, …item-n:This is also optional quantity. This indicates new item(s) to be added to the array
Example: Let us focus on example more. Here we will try to prove the delete operation via example. Here student names are given who have an account on GeeksForGeeks. We will try to delete one of the names from the array of student_names.
- How to insert an item at the beginning of an array in PHP ?
- PHP program to add item at the beginning of associative array
- Program to Insert new item in array on any position in PHP
- How to delete an array element based on key in PHP?
- Array.BinarySearch(Array, Object) Method with examples in C#
- PHP | Program to delete an element from array using unset() function
- How to search the max value of an attribute in an array object ?
- Convert an object to associative array in PHP
- How to convert an array into object using stdClass() in PHP?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.