How To Reload A Component In Angular Without Reloading The Whole Page
I want to reload a route but without reloading the entire page. This is not what I want: window.location.reload(); I want to reload just the component not the page. This is waht I
Solution 1:
the skipLocationChange option works for me,try my service
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
@Injectable()
export class ReloadRouteService {
constructor(
private router: Router,
) { }
redirectTo(url: string): void {
// When skipLocationChange true, navigates without pushing a new state into history.
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => {
this.router.navigate([url]);
});
}
}
Post a Comment for "How To Reload A Component In Angular Without Reloading The Whole Page"