I have the like following in my markup:
<div *ngFor="let item of someArray; let i = index">
<p [routerLink]="['profiles', profiles[i], 'posts', posts[i], 'likes', likes[i]]"</p>
</div>
In my Angular Component I have the following arrays:
profiles: any = []
posts: any = []
likes: any = []
Sometimes my "profiles" array might have elements and not my other arrays. If this happens then the routing will be broken. I have tried adding "?" to mark is as optional:
<p [routerLink]="['profiles', profiles[i]?, 'posts', posts[i]?, 'likes', likes[i]?]"</p>
This doesn't exactly work.