SortableJS / ngx-sortablejs

Angular 2+ binding to SortableJS. Previously known as angular-sortablejs
https://sortablejs.github.io/ngx-sortablejs/
MIT License
466 stars 160 forks source link

Hi, How to sort in multiple levels? #195

Open lybtt opened 4 years ago

lybtt commented 4 years ago

I'm using ngx-sortablejs, and I ran into a problem when implementing multi-level sorting.

my data like this:

chapters: [{ title: 'chapter 01', child: [{ title: 'topic 1-1' }, { title: 'topic 1-2' }] }, { title: 'chapter 02', child: [{ title: 'topic 2-1' }, { title: 'topic 2-2' }] }]

<div *ngFor="let chapter of chapters" [sortablejs]="chapters" [sortablejsOptions]="itemListOptions">
    <ul *ngFor="let topic of chapter.child" [sortablejs]="chapter.child" [sortablejsOptions]="itemListOptionsChild">

    </ul>
</div>

my question is: how can I get the chapter.child in itemListOptionsChild > onUpdate()? I need to get the currently selected array to sort.

(my English is not good, please forgive me)

lybtt commented 4 years ago

I see the demo(https://stackblitz.com/edit/angular-ptu94s), should I use component to implement multi-level sorting?