I have a modal wich is called when i click in a button, this is the modal logic:
export class SavedSearchesModalComponent implements OnInit, OnDestroy {
constructor() {
console.log('constructor');
}
ngOnInit() {
console.log('On init');
}
ngOnDestroy() {
console.log('On destroy');
}
}
at the first render is working fine, but when i navigate to another route and come back to the component which has the button to open the modal, and then open the modal again, this is the output result:
constructor
expected result:
constructor
On init
i applied this solution and it works fine:
constructor(public readonly cdr: ChangeDetectorRef) {
setTimeout(() => this.cdr.detectChanges(), 0);
console.log('constructor');
}
but i do not want to manipulate the life cycle of the component, i consider this a bad practice
NOTE: i’m using angular material to use the modal