<mat-select required formControlName="country" [(ngModel)]="defaultCountry" placeholder="Country"> <mat-option *ngFor="let key of Object.keys(countryList)" [value]="[key]">{{[key]}}</mat-option></mat-select>我有上面的代码。国家/地区在“材料选择”中显示良好,但是默认选项“ DefaultCountry”不起作用。我相信这是由于我使用Object.keys而引起的,因为以下代码确实可以使用默认选项。<mat-select required formControlName="country" [(ngModel)]="defaultCountry" placeholder="Country"> <mat-option *ngFor="let country of deleteLaterCountryList" [value]="country.countryCode">{{country.countryCode}}</mat-option></mat-select>我想知道如何使用默认选项使第一段代码正常工作。我不想使用第二段代码。
添加回答
举报
0/150
提交
取消
