angular 6 reload child component code example
Example 1: How to Reload a Component in Angular
reloadComponent() {
let currentUrl = this.router.url;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate([currentUrl]);
}
Example 2: reload a child component in angular
import { Component, Input, OnChanges } from "@angular/core";
@Component({
selector: "child-component",
templateUrl: "./child-component.html"
})
export class MyComponent implements OnChanges {
@Input() someInput: string;
constructor() {}
ngOnChanges() {
console.log(this.someInput);
}
}