DEV Community

Angga Lesmana
Angga Lesmana

Posted on

create variable data in button and share to another button

I have one simple case to create variable in button html share into another button

<td style="width: 3rem">
              <button
                mat-icon-button
                type="button"
                [matMenuTriggerData]="{ data: data }"
                class="cell-action"
                [matMenuTriggerFor]="actionsMenu"
                (click)="id = data.id"
              >
                <mat-icon
                  style="font-size: 24px"
                  [icIcon]="icMoreHoriz"
                ></mat-icon>
              </button>
            </td>
Enter fullscreen mode Exit fullscreen mode

see into [matMenuTriggerData] = {data: data}

  <ng-template let-data="data" matMenuContent>
    <button mat-menu-item [routerLink]="'./>
      <mat-icon [icIcon]="icPageView"></mat-icon>
      <span>Detail</span>
    </button>
    <!-- <button mat-menu-item (click)="dd(id)">
      <mat-icon [icIcon]="icArrowDownward">Canceled</mat-icon>
      <span>Unduh</span>
    </button> -->
    <!-- <button *ngIf="statusDelete"  mat-menu-item (click)="alertDialog(id)">
      <mat-icon [icIcon]="icDelete"></mat-icon>
      <span >Hapus</span>
    </button> -->
    <button *ngIf="data.status != 'Canceled'" mat-menu-item (click)="alertDialog(id)">
      <mat-icon [icIcon]="icDelete"></mat-icon>
      <span >Hapus</span>
    </button>
  </ng-template>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)