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

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

问题描述

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

How can I reload the current page on Angular 2?

如果在第2页(分页)中进行浏览并刷新页面,它将显示第1页(URL pageload)但我想刷新页面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天全站免登陆