What's alternative to angular.copy in Angular

后端 未结 15 1173
忘掉有多难
忘掉有多难 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条回答
  •  暖寄归人
    2020-11-29 01:32

    Use lodash as bertandg indicated. The reason angular no longer has this method, is because angular 1 was a stand-alone framework, and external libraries often ran into issues with the angular execution context. Angular 2 does not have that problem, so use whatever library that you want.

    https://lodash.com/docs#cloneDeep

提交回复
热议问题