AngularJavaScript Frameworks

DELETE One Item From a List in Angular

In this video, we’re going to implement a deleteFlight(id) function to remove a record from a list of flight data. For this exercise, we’re going to remove data from RAM only and not from a permanent data store. The best option for this operation is to use the two JavaScript built-in functions: findIndex() and splice(). First, we will use the findIndex() function to return the index position of a matching id field, then use the splice() function remove the element from the list.

The source files are available below.

Template file.

HTML

The source file (flight-list-component.ts)

JavaScript

The JSON data

JSON
Verified by MonsterInsights