Mustafa Mustafa - 1 year ago 673
TypeScript Question

Angular2 Component does not reinitialize for parameterized route

I have below test route with parameter T1:

path: 'Test/:T1',
component: TestComponent

When I route to 'Test/2' from 'Test/1' my
does not reinitialize. Is it an issue with angular router?

I am using
"@angular/router": "3.0.0-beta.1"

Answer Source

This is currently the only supported behavior. There are plans to make this configurable

You can subscribe to parameters change and do the initialization there

export class MyComponent {
    constructor(private route : ActivatedRoute,
      private r : Router) {}

    reloadWithNewId(id:number) {
        this.r.navigateByUrl('my/' + id + '/view');

    ngOnInit() {
      this.sub = this.route.params.subscribe(params => {

    paramsChanged(id) {
      // do stuff with id


See also How do I re-render a component manually?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download