typescript - Back button event does not fire Angular -


i trying redirect user particular url on click of button in browser, , here code

constructor(private router: router,private location: platformlocation) {                 let eventurl = window.sessionstorage.getitem('event');         this.location.onpopstate(() => {             alert('click');             this.router.navigate(['/', this.selectedlanguage, 'event', eventurl]);         });     } 

but not seem fire event when user click on button. code in current component. issue?

edit

i tried below answer suggested, not seems work, function getting called , still redirects previous page rather mentioned url below

unload(event: any) {         let eventurl = window.sessionstorage.getitem('buyerevent');         this.router.navigatebyurl('/' + this.selectedlanguage + '/event/' + eventurl);     } 

you can bind things want while leaving app window.unload event. here used hostlistener.

@hostlistener('window: unload', ['$event']) unload(event) {   window.open('https://localhost:4200', '_blank');   window.close(); } 

mention chrome block window.open default, have change block policy.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -