Angular 2 - Pass parameters to Route

前端 未结 3 1975
面向向阳花
面向向阳花 2020-12-16 13:43

I have a tag like below,

Person

So I want to pass the person.

3条回答
  •  旧时难觅i
    2020-12-16 14:21

    In my case, directive [routerLink] didn't work for me. So, I had to do it programmatically.

    Component template:

    Edit
    

    Component Class:

    import { Router } from '@angular/router';
    
    export class PersonComponent{
    
        constructor(private _route: Router){ }
    
        goToEdit(id){
            this._route.navigate(['Person/' + id]);
        }
    
    }
    

提交回复
热议问题