-
Notifications
You must be signed in to change notification settings - Fork 568
Allow to copy the dragged Item #85
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
Conversation
So you could use the draggables as templates to construct some new datastructure
Hey @robinboehm, thanks for the PR. May I know what problem does it solve? |
Hey :) |
I believe What do you say? |
Would be more intuitive, but I don't know the impact to other use cases of your plugin - so I've made this optional :) |
I am adding drag and drop support to the angular form builder component and I have been facing this issue where it adds new elements to the form by reference. Form elements are dragged from a sidebar and dropped to a form designer. |
Unfortunately, you lose the prototypical inheritance chain with this. angular.copy is weird because it flattens all prototypical functions, thus convoluting any future prototype wrapping. Can we add a property to specify shallow vs. deep copying? When shallow copying, use:
|
@mtraynham: but what problem does it create by not having prototypical chain? |
@codef0rmer You lose all references to the prototypical instance: My point being, angular.copy produces Object and can no longer be used with prototype's instanceof. I was using that to render objects differently in the dropped container as well as some other case statements. Now in the callback, if you received a shallow copy, you could recreate the instance with all of it's original properties. I do have a work around, so no biggie, just throwing this out there. As a side note, angular.copy returns an object with all prototype functions as constructor functions. Thus wrapping it again in the callback with the expected prototype inheritance will give you duplicate methods, with the constructor functions superseding the prototype ones. A bit convoluted and I am unsure of the issues that could introduce. |
So you could use the draggables as templates to construct some new datastructure