<mat-form-field>
<input matInput [(ngModel)]="info.dao">
</mat-form-field>
<mat-form-field class="example-full-width ">
<mat-label>Select Person</mat-label>
<mat-select [ngModelOptions]=
[(ngModel)]="info.selectionPerson">
<mat-option *ngFor="let info of info.comp" [value]="comp.id">
{{comp.location}}
</mat-option>
</mat-select>
</mat-form-field>
答案 0 :(得分:1)
您可以简单地使用[disabled]属性并传递类似以下内容的表达式:
<mat-form-field>
<input matInput [(ngModel)]="info.dao" [disabled]="info.selectionPerson">
</mat-form-field>
<mat-form-field class="example-full-width ">
<mat-label>Select Person</mat-label>
<mat-select [disabled]="info.dao"
[(ngModel)]="info.selectionPerson">
<mat-option *ngFor="let info of info.comp" [value]="comp.id">
{{comp.location}}
</mat-option>
</mat-select>
</mat-form-field>
您不需要ngModelOptions即可实现。