question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal doesn't call ngOnDestroy when closing

See original GitHub issue

When using modal with an external component like this:

<template #addEntity="" let-c="close">
  <add-entity [close]="c"></add-entity>
</template>

ngOnInit is being called but ngOnDestroy is never called (backdrop close or close function…).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
meshubhcommented, Mar 1, 2019

Is this issue fixed.

I still face the issue where in I try to close the modal using the .hide() method on the dialogRef but I still see the ngOnDestroy not being called.

bootstrap: 3.0.1 angular: 7.2.2

1reaction
pkozlowski-opensourcecommented, Sep 30, 2016

Looked into this one a bit and I can’t reproduce this with Angular only: https://plnkr.co/edit/AiqvW2yzAgY7LFXjwMWG?p=preview

At the same time I can clearly reproduce this with ng-bootstrap + modal: http://plnkr.co/edit/i3ajJvZ3bjQyk2I3rDmy?p=preview

Finally it might be an issue on our side and I think that I know what is going on. I need to investigate further to confirm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngOnDestroy works when open and closing component. Not ...
I have a toggle button that shows/hides the above component. When closing the component ngOnDestroy() works and the code executes properly. But, ...
Read more >
NgOnDestroy doesn't get called?. #ng_gotchas 1 | ng-gotchas
When the time came to have a service that needs to get destroyed when a component is destroyed I simply slapped “extends OnDestroy”...
Read more >
A Deep Dive into Angular's NgOnDestroy - Wesley Grimes
NgOnDestroy is a lifecycle method that can be added by implementing OnDestroy on the class and adding a new class method named ngOnDestroy...
Read more >
Ionic 4 ngOnDestroy not called from component on page ...
If I close the app I can see in chrome inspect that the ngOnDestroy is called. It just is not called when navigating...
Read more >
Closing a modal with the back button in Ionic 5 / Angular 9
Chances are you already have a method that dismisses your modal that you may call from a "cancel" or "close" button in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found