0

For example: I'm on this page, ciphxs? model = XS% 20Max & screen = 6.5 & color = 1 & capacity = 64GB

Clicking to go back I go to this page

ciphxs? model = XS% 20Max & screen = 6.5 & color = 1

Then clicking again would return to that page

ciphxs? model = XS% 20Max & screen = 6.5

I have a button that does this behavior, but I would use the browser button.

I am currently using typescript, but it would be nice to use JS even for the solution.

This is the div to back to the earlier page.

back() {
    this.capacity = null;
    this.canOrder = true;
    this.accepted = false;
    this.canOrderSubsidized = true;
    $(".final_selector").fadeOut(300)
    $(".capacity_selector").delay(300).fadeIn(300)
    $(".backCapacity").fadeOut(300)
    $(".backColor").delay(300).fadeIn(300)
  }

The div makes the result, but i want to make with the browser back button.

Thiago Cruz
  • 75
  • 1
  • 9

2 Answers2

1

Please, read Angular official documentation first. Then you'll be able to use Angular Router and define each needed route (url).

Back navigation will be possible with below code :

import { Component } from '@angular/core';
import { Location } from '@angular/common';

@Component({
  //...
})
class SomeComponent {
  constructor(private location: Location) {}

  back() {
    this.location.back();
  }
}

As mentioned in this answer.

Thierry Falvo
  • 5,892
  • 2
  • 21
  • 39
0

call the back function again on click og back button of browser.

window.onbeforeunload = function () {
   this.back();
}
indrajeet
  • 837
  • 10
  • 17