嗨,我是新手。我正在使用3行2列的席子桌子。我想在单击垫输入时连续启用/禁用垫按钮。我实现了click事件,但是该属性已分配给所有按钮。我希望将其连续分配给一个按钮。非常感谢您的帮助。
这是我的代码
html
<mat-table #user [dataSource]="activeDataSource">
<ng-container matColumnDef="email">
<mat-header-cell *matHeaderCellDef>Email</mat-header-cell>
<mat-cell *matCellDef="let user">
<mat-form-field floatLabel="never">
<input matInput placeholder="Email" [value]="user.email" [(ngModel)]="user.email" (click)="enableButton()">
</mat-form-field>
</mat-cell>
</ng-container>
<ng-container matColumnDef="save">
<mat-header-cell *matHeaderCellDef>Edit</mat-header-cell>
<mat-cell *matCellDef="let user">
<button mat-button [disabled]="disableButton" (click)="saveUser(user)" ng-disabled="true" color="primary" class="mat-raised-button mat-warn">
Save
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
TS
disableButton: boolean = true;
enableButton(){
this.disableButton = false;
}