I'm using this and i added selected in first option but its not working. Any suggestion?
<select class="select-dropdown" [(ngModel)]="selectedTickeDecisionType" (ngModelChange)="onChange($event)">
<option value="" selected>Odaberi tip odluke</option>
<option *ngFor="let decisionType of lovData.tticketdecisiontype" value="{{decisionType.code}}">{{decisionType.name}}</option>
</select>
When selectedTickeDecisionType
is initially null
[ngValue]="null"
on the first <option>
should do what you want:
<select class="select-dropdown" [(ngModel)]="selectedTickeDecisionType" (ngModelChange)="onChange($event)">
<option [ngValue]="null" selected>Odaberi tip odluke</option>
<option *ngFor="let decisionType of lovData.tticketdecisiontype" value="{{decisionType.code}}">{{decisionType.name}}</option>
</select>
You might need [ngValue]="decisionType.code"
on the other options to make this work properly (I haven't tried mixing value
and ngValue
myself yet).
<option
*ngFor="let decisionType of lovData.tticketdecisiontype; let i = index"
[ngValue]="decisionType.code"
[attr.selected]='i>0 ? "selected" : null'>
{{decisionType.name}}
</option>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With