1

Suppose ,I have three routes A->B->C ,I go to B from A ,and then to C from B

Now I want to move to A directly From C. Is this possible ?

gANDALF
  • 360
  • 4
  • 21

1 Answers1

0

You can try with Location Class in angular/common . It has method historyGo()

Example if you want to go to previous to previous component

 import {
    Location
} from "@angular/common"
class A {
    constructor(private location: Location) {}
    goBackTo() {
        this.historyGo(-1)

    }

}

    

As per docs

Position of the target page in the history relative to the current page. A negative value moves backwards, a positive value moves forwards, e.g. location.historyGo(2) moves forward two pages and location.historyGo(-2) moves back two pages

Also you can look at this answer

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shubham Dixit
  • 9,242
  • 4
  • 27
  • 46