html5-sortable-angularjs icon indicating copy to clipboard operation
html5-sortable-angularjs copied to clipboard

why using angular.copy

Open szabobgabor opened this issue 7 years ago • 1 comments

using angular.copy in handleDrop causes side effects hard to debug.

i had an array of objects, and elements were copyed to another array (lets call it helper array), sorting was based on this. after handleDrop, the object was replaced in helper array, but the original array kept the original object..

why you use angular.copy when creating the temp variable? what's the use case when it's needed?

szabobgabor avatar Mar 29 '19 10:03 szabobgabor

Hi. angular.copy I think will equivalent with _.clone ( underscore ) https://underscorejs.org/#clone as explain below

Create a shallow-copied clone of the provided plain object. Any nested objects or arrays will be copied by reference, not duplicated.

The reason I want to use "copy" to prevent for sure the data is isolation when handle on array.

bachvtuan avatar Mar 29 '19 10:03 bachvtuan