refresh page typescript code example
Example 1: angular 8 ts refresh page
refresh(): void {
window.location.reload();
}
Example 2: reload page in typescript
window.location.reload();
Example 3: typescript reload current page
import { DOCUMENT } from '@angular/common';
import { Component, Inject } from '@angular/core';
@Component({
selector: 'app-refresh-banner-notification',
templateUrl: './refresh-banner-notification.component.html',
styleUrls: ['./refresh-banner-notification.component.scss']
})
export class RefreshBannerNotificationComponent {
constructor(
@Inject(DOCUMENT) private _document: Document
) {}
refreshPage() {
this._document.defaultView.location.reload();
}
}
Example 4: angular typescript refresh page
this.router.routeReuseStrategy.shouldReuseRoute = function(){
return false;
};
this.router.events.subscribe((evt) => {
if (evt instanceof NavigationEnd) {
this.router.navigated = false;
window.scrollTo(0, 0);
}
});