角度模板绑定问题

时间:2019-06-19 15:18:27

标签: angular

我想在事件发射器中同时绑定模型值和局部变量值:

<tbody>
  <tr *ngFor="let model of source.data">
    <td *ngFor="let header of tableHeaders">
      <ng-container [ngSwitch]="header.type">
        <ng-template [ngSwitchCase]="'string'">
          {{model[header.propertyName]}}
        </ng-template>
        <ng-template [ngSwitchCase]="'date'">
          {{model[header.propertyName] | date}}
        </ng-template>
        <ng-template [ngSwitchCase]="'number'">
          {{model[header.propertyName]}}
        </ng-template>
      </ng-container>
    </td>
    <td>
      <div class="-icon-wrapper">
        <div *ngFor="let button of actionButtons" class="-icon-btn-wrapper">
          <!-- // I want to replace edit with button.action and id with                                                                     model.id  -->

          <button type='button' (click)="onAction$.emit({actionName: 'edit',     id: '123'})"
            class="btn                -icon-btn" ng-if="true">
            <div class="{{button.class}}"></div>
          </button>
        </div>
      </div>
    </td>
  </tr>
</tbody>

我不知道如何在按钮单击事件中绑定actionName和id。 有什么想法吗?

0 个答案:

没有答案