0
<div class="prod-div" *ngFor="let product of products; let i = index" [id]="i"  routerLink="/prod-desc"> 

I have this code above on my home component.

I want to use a service to pass the index value to the prod-desc component so that it can display details depending on the contents of the products array for the component. How can I do this thanks!

Jeremy Thille
  • 26,047
  • 12
  • 43
  • 63
sqpl13
  • 15
  • 2
  • like `[routerLink]="['/prod-desc', id]"`, make sure you have routing path as 'prod-desc:id' – navnath Oct 14 '21 at 09:18
  • Also take a look at this [How to pass index of an array from one component to another in angular2?](https://stackoverflow.com/questions/42939165/how-to-pass-index-of-an-array-from-one-component-to-another-in-angular2/42939297) – Deepa Subramanian Oct 14 '21 at 09:46

0 Answers0