remove item from stored array in angular 2

前端 未结 11 1895
长发绾君心
长发绾君心 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:27

    You can use like this:

    removeDepartment(name: string): void {
        this.departments = this.departments.filter(item => item != name);
      }
    

提交回复
热议问题