[angular] How to reload page the page with pagination in Angular 2?

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

This question is related to angular refresh angular2-routing reload page-refresh

The answer is


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.


Examples related to angular

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class error TS1086: An accessor cannot be declared in an ambient context in Angular 9 TS1086: An accessor cannot be declared in ambient context @angular/material/index.d.ts' is not a module Why powershell does not run Angular commands? error: This is probably not a problem with npm. There is likely additional logging output above Angular @ViewChild() error: Expected 2 arguments, but got 1 Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' Access blocked by CORS policy: Response to preflight request doesn't pass access control check origin 'http://localhost:4200' has been blocked by CORS policy in Angular7

Examples related to refresh

How to Refresh a Component in Angular Angular + Material - How to refresh a data source (mat-table) How to Update a Component without refreshing full page - Angular How to reload page the page with pagination in Angular 2? Swift: Reload a View Controller Button that refreshes the page on click Update data on a page without refreshing How to refresh or show immediately in datagridview after inserting? Gradle project refresh failed after Android Studio update Refresh Part of Page (div)

Examples related to angular2-routing

'router-outlet' is not a known element How to reload page the page with pagination in Angular 2? Error: Cannot match any routes. URL Segment: - Angular 2 Can't bind to 'routerLink' since it isn't a known property Passing data into "router-outlet" child components How to determine previous page URL in Angular? How to get parameter on Angular2 route in Angular way? Angular 2 Scroll to top on Route Change Angular routerLink does not navigate to the corresponding component Angular 2 router.navigate

Examples related to reload

How to reload page the page with pagination in Angular 2? Button that refreshes the page on click How to reload or re-render the entire page using AngularJS PHP refresh window? equivalent to F5 page reload? How do I detect a page refresh using jquery? Reload the page after ajax success How to reload a div without reloading the entire page? One time page refresh after first page load How can I refresh a page with jQuery? How to reload a page using JavaScript

Examples related to page-refresh

How to reload page the page with pagination in Angular 2? How to force reloading a page when using browser back button? How to reload a page after the OK click on the Alert Page Refresh a page using JavaScript or HTML Check if page gets reloaded or refreshed in JavaScript Force page scroll position to top at page refresh in HTML JavaScript hard refresh of current page