Search code examples
angularangular6angular-forms

Drop-down List Default value not showing Angular-6


Am trying to bind an array into a list .binding part is working fine.but the default value of drop down is not showing. Initially array doesn't have any value.

code

<select (change)="select($event)" [(ngModel)]="drp_selectedValue" >
                    <option value ="">Select.....</option>
                    <option *ngFor="let list of dataList?.length > 0 " (click)="select(list)" [ngValue]="list">{{list.name}}</option>

                </select>

currently my list showing like this

enter image description here

Am also tried to check dataList length and put value="" ,but not working.what was wrong in my code?


Solution

  • Initially set drp_selectedValue as ''

    drp_selectedValue = '';