Deep copy an array in Angular 2 + TypeScript

前端 未结 10 1136
温柔的废话
温柔的废话 2020-11-27 04:33

I have an array of objects that is an input. Lets call it content.

When trying to deep copy it, it still has a reference to the previous array.

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 05:20

    This is working for me:

    this.listCopy = Object.assign([], this.list);
    

提交回复
热议问题