I'm building a single page application with multiple views served by a router.
Most of the info I have read says to inject location:Location
as a service, then use (click)='location.back'
to go back a view.
This doesn't work for me as if you start on a certain view and click back, you end up exiting the app and going to the previous website. I also get frequent page reloads when using this as a navigation method. Is there a history API, or some other way to handle navigation in an ng2 application?
you can use location from angular common like:
import {Location} from '@angular/common';
constructor(private _location: Location){ }
goback(){
this._location.back();
}
Use This:
window.history.back();
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