remove item from stored array in angular 2

前端 未结 11 1890
长发绾君心
长发绾君心 2020-12-23 02:34

I want to remove an item from a stored array in angular 2, with Type Script. I am using a service called Data Service, the DataService Code:

export cl         


        
11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 03:11

    I think the Angular 2 way of doing this is the filter method:

    this.data = this.data.filter(item => item !== data_item);
    

    where data_item is the item that should be deleted

提交回复
热议问题