我很难验证角度材料表。我需要禁用保存按钮,直到所有字段都填写在垫表中。
我尝试使用模板驱动和反应方式的表单来做到这一点,但失败了。
这是html代码
<mat-card class="card">
<mat-card-title fxLayout.gt-xs="row" fxLayout.xs="columin">
<h3>Product Groups Editor</h3>
</mat-card-title>
<mat-card-content>
<div class="data-container">
<table mat-table [dataSource]="dataSource" matSort>
<tr mat-header-row *matHeaderRowDef="displayedColumns sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<ng-container matColumnDef="englishName">
<th mat-header-cell *matHeaderCellDef mat-sort-header class="table-header">English Name</th>
<td mat-cell *matCellDef="let element">
<input [disabled]="!element.active" [(ngModel)]="element.englishName" value="{{element.englishName}}">
</td>
</ng-container>
<ng-container matColumnDef="color">
<th mat-header-cell *matHeaderCellDef class="table-header">Color</th>
<td mat-cell *matCellDef="let element">
<input [disabled]="!element.active" [(colorPicker)]="element.color" [style.background]="element.color" />
</td>
</ng-container>
<ng-container matColumnDef="level">
<th mat-header-cell *matHeaderCellDef mat-sort-header class="table-header">Level</th>
<td mat-cell *matCellDef="let element">
<mat-form-field appearance="outline">
<mat-select placeholder="Level" [disabled]="!element.active" [(ngModel)]="element.groupLevel">
<mat-option *ngFor="let eachLevel of allGroupLevel" [value]="eachLevel.groupLevelId">
{{eachLevel.name}}
</mat-option>
</mat-select>
</mat-form-field>
</td>
</ng-container>
</table>
</div>
<div>
<button id="addButton" (click)="addGroup()" mat-raised-button color="primary">
<mat-icon>add</mat-icon>Add Group
</button>
<button id="saveButton" (click)="saveGroups()" mat-raised-button color="primary">
<mat-icon>save</mat-icon>Save Groups
</button>
</div>
</mat-card-content>
</mat-card>
如果有人可以提供帮助,我将不胜感激。