How do i support RouteParams on page reload using Angular 2 Dart? How do i support RouteParams on page reload using Angular 2 Dart? dart dart

How do i support RouteParams on page reload using Angular 2 Dart?


If I understand your question correctly, you need to subscribe to the router events in your component to update the old params with new, and then update your UI.

I assume your problem is when you open an url http://localhost:8080/#/picker/SAN/SFO/2015-01-01/2015-04-02, and then navigates to http://localhost:8080/#/picker/SAN/SFO. What you do is changing the route, but the component is already instantiated, meaning the new param will not be updated (nor removed).What I usually do is the following in your parent component

Angular 5

constructor(private router:Router){ // Subscribe to the router events.  // It may be a good idea to assign this subscription to a variable, and then do an unsubscribe in your ngOnDestroy(). this.router.events.subscribe(event=>{   if(event instanceof ActivationEnd){   var cityDepart = event.snapshot.params["cityDepart"];   var cityArrival = event.snapshot.params["cityArrival"];   var dateDepart = event.snapshot.params["dateDepart"];    var dateArrival = event.snapshot.params["dateArrival"];   // do some logic  } });}