我正在尝试将一个占位符添加到Angular 4上的选择但是无法使其工作,
这是我的代码:
<select name="edit" [(ngModel)]="edit">
<option [ngValue]="null" disabled [selected]="true"> Please select one option </option>
<option *ngFor="let select of list" [ngValue]="edit"> {{ select }}</option>
</select>
export class AppComponent {
list: any[] = ['1', '2', '3'];
edit: any;
}
Run Code Online (Sandbox Code Playgroud)
ale*_*nko 26
我创造了plunker.希望这会有所帮助.
<select name="edit" [(ngModel)]="edit">
<option [ngValue]="undefined" disabled selected> Please select one option </option>
<option *ngFor="let select of list" [ngValue]="edit"> {{ select }}</option>
</select>
export class AppComponent {
list: any[] = ['1', '2', '3'];
edit: any;
}
Run Code Online (Sandbox Code Playgroud)