Is there a smart way to go back last page in Angular 2?
Something like
this._router.navigate(LASTPAGE);
For example, page C has a Go Back button,
Page A -> Page C, click it, back to page A.
Page B -> Page C, click it, back to page B.
Does router have this history information?
Right-click, or click and hold either the Back or Forward arrow in the browser toolbar. Goes to the previous page in your browsing history for the tab. Press Backspace , or Alt and the left arrow together.
No, by far the best way to jump to the top or bottom of a Web page is by tapping your Home or End key, respectively. This works in Chrome, Firefox, and Internet Explorer (and probably every other browser as well–those are just the ones I've tested). Try it–I guarantee it'll join your list of favorite shortcuts.
The history. back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.
In the current version of Firefox, which is Firefox 84 as of now, you can use either Backspace, Alt + Left arrow, or a toolbar button to go to a previous web site (if any) on Windows.
Actually you can take advantage of the built-in Location service, which owns a "Back" API.
Here (in TypeScript):
import {Component} from '@angular/core'; import {Location} from '@angular/common'; @Component({ // component's declarations here }) class SomeComponent { constructor(private _location: Location) {} backClicked() { this._location.back(); } }
Edit: As mentioned by @charith.arumapperuma Location
should be imported from @angular/common
so the import {Location} from '@angular/common';
line is important.
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