angular2: how to copy object into another object

后端 未结 8 909
失恋的感觉
失恋的感觉 2021-01-30 10:05

Please help me in order to copy the object into another object using angular 2?

In angular, I used angular.copy() to copy objects to the loose reference of the old object

8条回答
  •  不知归路
    2021-01-30 10:38

    Try this.

    Copy an Array :

    const myCopiedArray  = Object.assign([], myArray);
    

    Copy an object :

    const myCopiedObject = Object.assign({}, myObject);
    

提交回复
热议问题