I'm currently trying to generate a dynamic menu from a JSON blob in my typescript files, Angular project.
I'm using the / component from Angular Material.
My json menu has this structure :
{
        id: 0,
        titreTranslate: 'menu-accueil',
        isDescriptionRequired: true,
        routerLink: '/accueil',
        icon: faHome,
        isAllowed: true,
        hasSubOptions: false,
        trigger: 'accueil'
}
My code look something like this :
<mat-toolbar-row class="navigation-row">
    <span *ngFor="let option of menuOptions">
        <button mat-button
                [matMenuTriggerFor]="admin"
                routerLink="{{option.routerLink}}"
                (keyup.enter)="router.navigate([option.routerLink], { queryParams: option.queryParams })"
                [routerLinkActive]="['active-menu']"
                [queryParams]="option.queryParams"
                class="link bouton-menu-gauche flex-row"
                *ngIf="option.isAllowed"
        >
          <fa-icon
            *ngIf="option.icon"
            class="primary-color"
            [icon]="option.icon"></fa-icon>
            {{ option.titreTranslate | translate }}
        </button>
      <mat-menu #{{option.trigger}}="matMenu">
        <span *ngFor="let subOption of option.menuOptions">
          <button mat-menu-item
            *ngIf="option.menuOptions"
            routerLink="{{subOption.routerLink}}"
            (keyup.enter)="router.navigate([subOption.routerLink], { queryParams: subOption.queryParams })"
            [routerLinkActive]="['active-menu']"
            [queryParams]="subOption.queryParams"
            class="link bouton-menu-gauche flex-row">
            <fa-icon
              *ngIf="subOption.icon"
              class="primary-color"
              [icon]="subOption.icon"></fa-icon>
              {{ subOption.titreTranslate | translate }}
          </button>
        </span>
      </mat-menu>
    </span>
  </mat-toolbar-row>
The line with " <mat-menu #{{option.trigger}}="matMenu"> " is what concerns me here ; I've tried many ways to variabilize this #, such as putting it directly in the Json menu or trying different syntax ; It always fail, and won't give me the code structure i want.
If i had to guess, i'd say the generated code should look like : <mat-menu #"accueil"="matMenu">, with "" that fail to compile ; but i don't get any compilation errors, so i'm lost here.
Does anybody had to work with that kind of structure before ?
(apologies for my english if it's bad, i'm french)
 
    