Handle back button


#1

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 uts only make the ngOnDestroy fire but not the ngOnInit
did someone had the same problem and how did you handle it ?


#2

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();
});
}