Reputation: 75
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.
Upvotes: 0
Views: 254
Reputation: 897
call the back function again on click og back button of browser.
window.onbeforeunload = function () {
this.back();
}
Upvotes: 0
Reputation: 6290
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.
Upvotes: 1