You can't use delete to remove an item from an array. This is only used to remove a property from an object.

You should use splice to remove an element from an array:

deleteMsg(msg:string) {
    const index: number = this.data.indexOf(msg);
    if (index !== -1) {
        this.data.splice(index, 1);
    }        
}
Answer from Poul Kruijt on Stack Overflow
🌐
Angular Wiki
angularjswiki.com › angular › how-to-remove-an-element-from-array-in-angular-or-typescript
How To Remove an element from Array in Angular/Typescript | Angular Wiki
To remove an element from an array in Angular or Typescript we can use javascript’s delete operator or Array splice function.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-do-i-remove-an-array-item-in-typescript
How do I Remove an Array Item in TypeScript? - GeeksforGeeks
July 23, 2025 - We can use the following methods to remove items from a TypeScript array: ... The splice method can be used to delete multiple elements by specifying the start index from where the deletion of the element will start and the number of elements to be deleted as parameters to it.
🌐
ItSolutionstuff
itsolutionstuff.com › post › angular-how-to-remove-element-from-arrayexample.html
Angular How to Remove Element from Array? - ItSolutionstuff.com
May 2, 2024 - Here, i will show you how to works angular remove element from array. We will use angular remove element from array by index. This article goes in detailed on angular delete element from array by value.
🌐
Ultimate Courses
ultimatecourses.com › blog › remove-specific-item-from-array-javascript
Removing Items from an Array in JavaScript - Ultimate Courses
So now we understand a little more about mutable and immutable, let’s uncover the immutable pattern to “remove” an element from an array. The best way you can think about this is - instead of “removing” the item, you’ll be “creating” a new array that just does not include that item. So we must find it, and omit it entirely. Directives, simple right? Wrong! On the outside they look simple, but even skilled Angular devs haven’t grasped every concept in this eBook.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › typescript tutorial › typescript remove item from array
TypeScript remove item from array | Learn the Examples and Parameters
April 6, 2023 - In typescript, to remove or delete any item in the array, we can use the delete operator as JavaScript, but it will remove the property of the object of the array where it cannot shift any index or key values.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Top answer
1 of 3
44

You could use Array#filter method:

food = {
  id: 1,
  name: 'Pizza',
  price: 16
};

orders = [
  { food_id: 2, table_id: 5 },
  { food_id: 2, table_id: 5 },
  { food_id: 1, table_id: 5 },
  { food_id: 3, table_id: 5 },
  { food_id: 1, table_id: 5 }
];

removeFoodOrder(food: Food): void {
  this.orders = this.orders.filter(({ food_id }) => food_id !== food.id);        
}

Edit:

Since your array allows duplicate elements and you want to remove only the first match, you could use the Array#findIndex + Array#filter methods:

const foundIndex = this.orders.findIndex(({ food_id }) => food_id === food.id);
this.orders = this.orders.filter((_, index) => index !== foundIndex);
2 of 3
3

The first step for me is always to remove anything confusing like that ternary operator and your break stmt. Here's how I did it

let food = {
  id: 1,
  name: 'Pizza',
  price: 16
}

let orders = [
    {food_id: 2, table_id: 5},
    {food_id: 2, table_id: 5},
    {food_id: 1, table_id: 5},
    {food_id: 3, table_id: 5},
    {food_id: 1, table_id: 5}
]

for (let order of this.orders) {
    if (food.id === order.food_id) {
        this.orders.splice(this.orders.indexOf(order), 1);
        break;
    }
}
console.log(this.orders);

I would recommend against using Array#filter if you don't know 100% how to use it.

UPDATE I am not saying don't use the Array#filter method. I'm just saying that if your code isn't working, you should try to remove anything that could be causing your issue and try to go about it step by step using simple constructs (like a for loop and if stmt).

Find elsewhere
🌐
10xdev
10xdev.blog › angular-remove-item-from-array
Remove an item from an array in Angular | Techiediaries
The following example shows how to use the splice() method to remove an item from an array in Angular:
🌐
WebDevAssist
webdevassist.com › typescript › typescript-remove-first-element-array
How to remove the first element from an array in TypeScript
It takes the starting index and the number of elements to delete from the array as its parameters. It deletes all elements from the original array and returns one new array holding the deleted elements. We can use splice to remove the first element from an array.
🌐
GeeksforGeeks
geeksforgeeks.org › angularjs › how-to-remove-an-item-from-an-array-in-angularjs-scope
How to remove an item from an array in AngularJS Scope? - ...
July 23, 2025 - In this approach, we are using the filter method for removing the array element or item in the AngularJS scope. The 'filter' method in AnngularJS initially creates a new array with all the items that pass the function.
🌐
TutorialsPoint
tutorialspoint.com › home › typescript › typescript array splice method
TypeScript Array Splice Method
December 18, 2016 - TypeScript - null vs. undefined ... howMany − An integer indicating the number of old array elements to remove. If howMany is 0, no elements are removed. element1, ..., elementN − The elements to add to the array. If you don't specify any elements, splice simply removes the elements from the array.
🌐
Delft Stack
delftstack.com › home › howto › typescript › remove an array item in typescript
How to Remove an Array Item in TypeScript | Delft Stack
February 2, 2024 - let array = ["white", "yellow", "black", "green", "blue"]; let removed = array.splice(3, 1, "red"); console.log("The new array is : " + array ); console.log("The color that was removed is : " + removed); ... The shift() method can delete an ...
🌐
Webdevtutor
webdevtutor.net › blog › typescript-angular-remove-element-from-array
Removing Elements from an Array in Angular Using TypeScript
One of the most common ways to remove elements from an array in TypeScript is by using the filter method. This method creates a new array with all elements that pass a certain condition. Here's an example of how you can use the filter method to remove elements from an array in Angular:
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › typescript – how to remove items from array
TypeScript - How to Remove Items from Array
July 26, 2023 - Remove the element and create a new array of remaining elements. Learn to remove or pop items from an array in TypeScript using pop(), shift(), splice(), filter() and delete operator with examples.