I have a child form component that gets created in material tabs:
<md-tab *ngFor="let selectedEntity of selectedEntities; let i=index">
<template md-tab-label>{{selectedEntity.resource.name}}
<i class="fa fa-times" (click)="onTabClose(i)"></i>
</template>
<child-form [entity]="selectedEntity"></child-form>
</md-tab>
I'm using ngOnDestroy to show a material dialog asking if the user wants to save when closing the tab.
ngOnDestroy(): void {
this.promptService.open(this);
};
However, since the current state is saved in a service, I don't need to show the prompt when the user changes the route, only when they close a tab.
Can I (and if so, how can I) check if a route change is causing the child component to be destroyed?