I have a mega nav menu that is made by looping through a JSON response from server. I want to add a #first template reference variable to the first a tag. (This is so that I can access it from its parent component to add focus to that link if a user uses the keyboard to select that part of mega nav; to make it accessible.) Below isn't working. How do you do this?
<li *ngFor="let item of subMenu.items; let itemIndex=index;">
<a (click)="linkMegaClicked($event)"
[routerLink]="item.url"
[#first]="itemIndex == 0"
[innerHtml]="item.link_text">
</a>
</li>
I Don't think you can add this dynamically (you can't do this with directives either) so i'm afraid you'll need to create 2 html tags.
I'f there is a way i'm sure somebody will correct me but for what I know this will be the way.