All these solutions did not work properly for me. In the end i used a service to reload the page:
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ReloadHomeService {
private reloadRequest = new Subject<void>();
reloadRequest$ = this.reloadRequest.asObservable();
requestReload() {
this.reloadRequest.next();
}
}
With this I can just insert the service in the component where I want to trigger the reload:
this.reloadHomeService.requestReload();
In my home component:
this.reloadHomeService.reloadRequest$.subscribe(() => {
// Do something to reload the data for this page
});
In this way, angular does only reload the necessary parts of the component, not the whole page.