Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is safe method to perform `Object.assign` when using AngularJS?

Tags:

angularjs

Basically I would like to perform Object.assign to get copy of my data, without anything that AngularJS attached in the past, it attaches now, or may attach in future versions.

Sure I can delete such property as $$hashKey after assignment but this approach is totally fragile, on the other hand I could manually construct the object with fields I want but this on the other hand is tiresome (and also fragile if I change definition of my source object).

Is there something solid in between?

like image 664
greenoldman Avatar asked Dec 01 '25 04:12

greenoldman


1 Answers

There are no other properties as $$hashKey, it is one of a kind.

All of Angular object helpers are aware of this property and remove it at the end of the operation. angular.extend is a direct Angular counterpart of Object.assign and should be used instead.

like image 185
Estus Flask Avatar answered Dec 02 '25 20:12

Estus Flask



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!