[英]I need to use the browser button to go back to the previous dynamic page
For example: I'm on this page, ciphxs? 例如:我在此页面上,ciphxs? model = XS% 20Max & screen = 6.5 & color = 1 & capacity = 64GB
型号= XS%20Max&屏幕= 6.5&颜色= 1&容量= 64GB
Clicking to go back I go to this page 点击返回我去这个页面
ciphxs? ciphxs? model = XS% 20Max & screen = 6.5 & color = 1
型号= XS%20Max和屏幕= 6.5&颜色= 1
Then clicking again would return to that page 然后再次单击将返回该页面
ciphxs? ciphxs? model = XS% 20Max & screen = 6.5
型号= XS%20Max和屏幕= 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. 我目前正在使用打字稿,但即使是解决方案也可以使用JS。
This is the div to back to the earlier page. 这是返回上一页的div。
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. 的div使结果,但我想用浏览器的后退按钮。
Please, read Angular official documentation first. 请先阅读Angular官方文档 。 Then you'll be able to use Angular Router and define each needed route (url).
然后,您将能够使用Angular Router并定义每个所需的路由(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 . 正如这个答案中提到的。
call the back function again on click og back button of browser. 单击浏览器的后退按钮再次调用后退功能。
window.onbeforeunload = function () {
this.back();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.