How to reload page the page with pagination in Angular 2?

AngularRefreshAngular2 RoutingReloadPage Refresh

Angular Problem Overview


How can I reload the current page on Angular 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

Angular Solutions


Solution 1 - Angular

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

HTML:

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

TS:

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

Update:

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFABI1987View Question on Stackoverflow
Solution 1 - AngularAlexander StaroselskyView Answer on Stackoverflow