我在我的角度应用程序中有一组带有值的下拉菜单。
在视图 Screen 中,下拉菜单不显示所选值(保存在 db 中的值),而是显示“选择”。
HTML:
<p-dropdown [options]="reasons" [(ngModel)]="selectedReason" (onChange)="getCompleteReason($event)" styleClass="ui-column-filter" filter="true"> </p-dropdown>
组件.ts
this.reasons = [];
this.reasons.push({label: 'Select', value: null});
this.reasons.push({label: 'Reason 1', value: 'Reason 1'});
this.reasons.push({label: 'Reason 2', value: 'Reason 2'});
this.reasons.push({label: 'Reason 3', value: 'Reason 3'});
this.reasons.push({label: 'Other', value: 'Other'});
this.selectedReason = 'Reason 2' (eg value stored in the db)