Prevent ngOnDestroy from being called when moving components using ngx-drag-drop in Angular

Discussão em 'Angular' iniciado por Abdullah Khalid, Setembro 23, 2024.

  1. I'm using the ngx-drag-drop library in my Angular application to allow users to drag and drop components. However, I am facing an issue where the ngOnDestroy lifecycle hook is being triggered when I move an already dropped component from one position to another within the list.

    For example, when I move a component from index 2 to index 3, the ngOnDestroy method is called, even though I am just changing the component's position. I only want ngOnDestroy to be triggered when the component is being removed (not when it's just moved).

    Is there a way to prevent ngOnDestroy from being called during a move action with ngx-drag-drop? I want to retain the component's state and only trigger ngOnDestroy when the component is being fully removed, not when it's simply being reordered.

    Continue reading...

Compartilhe esta Página