What's alternative to angular.copy in Angular

后端 未结 15 1168
忘掉有多难
忘掉有多难 2020-11-29 00:43

How can I copy an object and lose its reference in Angular?

With AngularJS, I can use angular.copy(object), but I\'m getting some error using that in An

15条回答
  •  Happy的楠姐
    2020-11-29 01:24

    let newObj = JSON.parse(JSON.stringify(obj))
    

    The JSON.stringify() method converts a JavaScript object or value to a JSON string

提交回复
热议问题