I have a component and I need to detect if user pressed back button in his browser to navigate back.
Currently I\'m subscribing router events.
constr
IMO better method of listenting for popstate events is to subscribe to location service
import {Location} from "@angular/common";
constructor(private location: Location) { }
ngOnInit() {
this.location.subscribe(x => console.log(x));
}
It doesn't use PlatformLocation directly (as documentation suggest) and you can unsubscribe any time you want.