i have location drop down in top nav bar. on change location, i have to load entire application based on that location data, so i need to get all components data to be refreshed, that is why i am approaching this step.
core.js:5847 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'RefreshComponent' Error: Cannot match any routes. URL Segment: 'RefreshComponent'
constructor( private router: Router, ) { } i have used javascript setTimeout(() => { location.reload(); }); it worked fine, i dont want to reload the page, just want to refresh the component i tried below code. but when i use console error is coming.
changeLocation(locationData) { this.router.navigateByUrl('/RefreshComponent', { skipLocationChange: true }).then(() => { this.router.navigate([this.router.url]); }); } Am i missing any configuration .?
RefreshComponent?ngOnInitthere. Best practice though would be to just trigger a new fetching of current data and subscribe to them via Observables. Then you should not have to reload the component.