如何在 Angular 2 中使用分页重新加载页面? [英] How to reload page the page with pagination in Angular 2?

查看:28
本文介绍了如何在 Angular 2 中使用分页重新加载页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Angular 2 上重新加载当前页面?

How can I reload the current page on Angular 2?

如果我在第 2 页(分页)并刷新页面,它将显示第 1 页(URL 页面加载)但我想刷新第 2 页,它会出现在第 2 页

if iam in page 2 (pagination) and refresh the page it will show page 1(URL pageload) but i want i refresh the page 2 and it will appear in page 2

推荐答案

这在技术上应该可以使用 window.location.reload() 实现:

This should technically be achievable using window.location.reload():

HTML:

<button (click)="refresh()">Refresh</button>

TS:

refresh(): void {
    window.location.reload();
}

更新:

这是一个基本的 StackBlitz 示例,显示了正在执行的刷新.请注意,在执行 window.location.reload() 时,会保留/hello"路径上的 URL.

Here is a basic StackBlitz example showing the refresh in action. Notice the URL on "/hello" path is retained when window.location.reload() is executed.

这篇关于如何在 Angular 2 中使用分页重新加载页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆