I am working with angular 8 and want to refresh my component on same url without refresh whole page. I am trying with router.navigate but its not working for me. I tried with
location.reload
andwindow.location.reload
but it takes too much time and it refresh whole page. Below is my code for same :
this.snackBar.open('Data Updated Successfully', 'Undo', {
duration: 5000,
});
this.router.navigate(['/get_customer_details/'+this.customer_details_id]);
console.log(this.customer_details_id);
this.ngOnInit();
By default RouteReuseStrategy
of Angular is true. You need to cahnge it to false.
Use the following code in your constructor
constructor(private route: ActivatedRoute, private router: Router) {
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With