How to select first option in select?

angular

Solution

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).

Problem

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> ```

Original source