Skip to content

Commit

Permalink
fix(SwalPortalDirective): fix Angular view not freed when modal is cl…
Browse files Browse the repository at this point in the history
…osed by another modal

Fixes #147
  • Loading branch information
toverux committed Jan 31, 2020
1 parent 832cfff commit 038ca07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SwalPortalDirective implements OnInit, OnDestroy {
//=> Subscribe to a few hooks frm the parent SwalComponent.
this.swalComponent.render.pipe(takeUntil(this.destroyed)).subscribe(this.renderHook.bind(this));
this.swalComponent.beforeOpen.pipe(takeUntil(this.destroyed)).subscribe(this.beforeOpenHook.bind(this));
this.swalComponent.afterClose.pipe(takeUntil(this.destroyed)).subscribe(this.afterCloseHook.bind(this));
this.swalComponent.destroy.pipe(takeUntil(this.destroyed)).subscribe(this.destroyHook.bind(this));
}

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ export class SwalPortalDirective implements OnInit, OnDestroy {
* This afterClose hook runs once (per modal instance), just after the modal closing animation terminated.
* This is a good place to detach and destroy our content, that is not visible anymore.
*/
private afterCloseHook(): void {
private destroyHook(): void {
if (!this.portalComponentRef) return;

//=> Detach the portal component from the app and destroy it
Expand Down

0 comments on commit 038ca07

Please sign in to comment.