4

I have drag and drop option with a tree structure, but all the nodes are made siblings due to some functionalities, So that we can make any node as parent.

I am using Dragula ng2-dragula for drag and drop.

If I drag a parent, I need to move all the children along with the parent (Its enough to move the child after drop the parent).

HTML

<tbody [dragula]='"edit-tags-drag"' [dragulaModel]="structure" #tagsBag>

When I modify the structure array manually in ts file, the view is not updating.

TS File

constructor(public store: Store<any[]>,
          private dragulaService: DragulaService,
          private translate: TranslateService,
          private appRef: ApplicationRef,
          private ref: ChangeDetectorRef) {};
ngOnInit () {
    this.dragulaService.dropModel.subscribe((item) => {
//Updating the structure
     }
}

I tried

this.ref.detectChanges();
this.ref.markForCheck();
this.appRef.tick();
setTimeout();

as well. If I am having separate button and binding click event, View is updating. Any sort of help would be great.

Edit: Plunker link added

Balaji Perumal
  • 721
  • 5
  • 17

0 Answers0