How to pass and get parameter with routerLink in Angular 2?

后端 未结 5 861
终归单人心
终归单人心 2021-02-06 06:30

I want to pass a value with url using routerLink. And read that value on another page. Like I have product list. On select of first record the id of that record pass to product

5条回答
  •  后悔当初
    2021-02-06 07:08

    you can use this in .html

    [routerLink]="['/trips/display/' + item.trip, {'paramKey': 'application'}]"
    

    and in .ts you can use this to recover the params

    this.id = this.route.snapshot.params['id'];
    const param = this.route.snapshot.params['paramKey'];
    

提交回复
热议问题