Angular 2 - sending an object from one component to another through a link router

I am trying to send an object via router-link in angular 2. I create a personal profile component for each object object in my personal array and display it on the screen.

<div *ngFor="#person of people; #i = index">
    <person-profile  [person]="person"></person-profile>
</div>

The person-profile component displays several pieces of information contained in a person object. Im trying to send the whole person’s object from the personal profile component to a component named “map” using a link router and passing the person object as a parameter.

<person-profile>
  ..code..
    <tr>
       <td class="category">Address</td>
       <td>{{ person.visiting_address }}</td>
       <td *ngIf="person.visiting_address"><a [routerLink]="['Map',{person:person}]">View on map</a></td>
    </tr>
..code..
<person-profile>

In my map component, I get the object with:

var person = <any> routeParams.get('person');

, , , <person-profile> -. . , person, . , person.family_name person, , . ?

!

+4
1

AFAIK , RouterLink - , URL.

- , .

+10

All Articles