Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why using angular.copy #17

Open
szabobgabor opened this issue Mar 29, 2019 · 1 comment
Open

why using angular.copy #17

szabobgabor opened this issue Mar 29, 2019 · 1 comment

Comments

@szabobgabor
Copy link

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?

@bachvtuan
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants