3

In angular 1 with UI Router when I go to the same route but different param. Angular will reload the view. But in Angular 2 it doesn't. It just updates the data. But I need the user to feel like the page is transitioning to a different page.

What I have already tried is forcing angular 2 to route to a dummy route/component and then back to the designated route. I am using angular animations when transition from a route to a different a route. So this method has a bit of a delay and looks weird.

{path: "product/:id" }

routerLink="/product/30"
Raymond the Developer
  • 1,576
  • 5
  • 26
  • 57

1 Answers1

1

This answer is very helpful https://stackoverflow.com/a/38129910/9027171

1 - You should add ActivatedRoute

import {Router, ActivatedRoute} from '@angular/router';

2 - and in Constructor

constructor(private activatedroute: ActivatedRoute,...

3 - and on ngOnInit() :

this.activatedroute.params.subscribe(params => {
      console.log(params, params['rowid']);
      this.id = params['rowid']
        }
    });

After Subscribing your params will changed after navigation NB : params['here_put_your_param_name']

Thank you :)

thor
  • 21,418
  • 31
  • 87
  • 173
Abdelhadi Abdo
  • 392
  • 2
  • 9