0

I need to pass object value to another component while navigating from one component to another without showing data in URL.

I m trying something like this, when clicking it will redirect to secondComponent. in URL i will show /15 but i also i want to pass object to secondcomponent that should not visiable on url.

Could someone please tell me how to pass object at the time of navigation and how to capture it on second component

Is it possible to sent obj value inside [routerLink]="15 passThisObj"

Eg:

{ path: ':id', component: SecondComponent }


<a [routerLink]="15 passThisObj1">Edit</a>
<a [routerLink]="16 passThisObj2">Edit</a>
<a [routerLink]="17 passThisObj3">Edit</a>
<a [routerLink]="18 passThisObj4">Edit</a>
<a [routerLink]="19 passThisObj5">Edit</a>
user3419304
  • 249
  • 2
  • 4
  • 20

1 Answers1

0

What you are asking is not technically possible with angular, the only way to pass data as part of a routerLink is by modifying the URL. However if the data to be passed is related to the route parameter in a one-to-one relationship, you can store those objects in an object in a service, and in your component (the one being routed to) use that service to query the data object based on the route parameter.

Aviad P.
  • 32,036
  • 14
  • 103
  • 124