reppners / ngx-drag-drop

Angular directives using the native HTML Drag And Drop API
https://reppners.github.io/ngx-drag-drop/
BSD 3-Clause "New" or "Revised" License
299 stars 118 forks source link

recursive data model #28

Closed gnututor closed 5 years ago

gnututor commented 6 years ago

the library get a "TypeError: Converting circular structure to JSON" when you handle a recursive data model

https://stackblitz.com/edit/ngx-drag-drop-issue-template-cx9zgp?file=src/app/app.component.html

reppners commented 6 years ago

I see where you're coming from but I'm not planning to add support for recursive data structures as drag data. There is almost always a better alternative than heavy serialization in drag/drop:

To handle recursive data structures, build a service/data store that will enable you to reference your drag data by an id string/number and just set the id as your drag data. In your drop handlers get the data by the id and operate on it as you need.

If you need further help or an example implementation let me know.

gnututor commented 6 years ago

thank you for reply!!

Yes, it will be useful to have your example implementation.

For now, my solution was to build a data structure where data are logically in that structure but physically in a map. The map is queried by the structure (via service) to retrieving data.

reppners commented 5 years ago

Basically your solution is the same to what I would've suggested showcased. Closing as solved/answered.