Modal doesn't call ngOnDestroy when closing
See original GitHub issueWhen 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:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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.