I have a problem handling the back button , when the user taping the back button the ngOnInit is not triggered and the component is not working as wanted . from what i saw i understand that when taping back its only make the ngOnDestroy fire but not the ngOnInit
this is the lifecycle
open App --> ngOnInit() called
click on some anther component --> ngOnInit() of the new component called
tap back --> ngOnDestroy
Did someone had the same problem and how did you handle it ? thank you
After some search i decided to use this solution
in components that i need the ngOnInit to run even if the navigate is from the back button or function i added this
constructor(private location : PlatformLocation) {}
ngOnInit() {
this.location.onPopState(() => {
this.initComponent();
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With