Give placeholder to select in Angular 6

后端 未结 7 2513
萌比男神i
萌比男神i 2021-02-19 15:25

I have a select option in which i want to give placeholder which says \"select a category\"

相关标签:
7条回答
  • 2021-02-19 16:07

    simply use [value]="undefined"

    <select class="form-control" [(ngModel)]="selectedCategory">
        <option [value]="undefined" disabled hidden>Select...</option>
        <option *ngFor="let c of categories">{{c}}</option>
    </select>
    
    0 讨论(0)
提交回复
热议问题