为了账号安全,请及时绑定邮箱和手机立即绑定

在ngFor循环中使用Object.keys时如何设置默认值?

在ngFor循环中使用Object.keys时如何设置默认值?

心有法竹 2021-05-15 14:08:20
<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>我想知道如何使用默认选项使第一段代码正常工作。我不想使用第二段代码。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 225 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号