Sometimes, we want to go back last page with Angular.
In this article, we’ll look at how to go back last page with Angular.
How to go back last page with Angular?
To go back last page with Angular, we can call the location.back
method.
For instance, we write
import { Component } from "@angular/core";
import { Location } from "@angular/common";
@Component({
// ...
})
class SomeComponent {
constructor(private location: Location) {}
backClicked() {
this.location.back();
}
}
to inject location
in the `constructor.
Then in the onClick
method, we call this.location.back
to go back to the last page.
How to go back last page with Angular?
To go back last page with Angular, we can call the location.back
method.