Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic select first option from dynamic values

I am trying to select first option in ionic select I write condition with indexs which if index is 0 checked = true still not working here is my Code:

<ion-item>
            <ion-label>Venue Name</ion-label>
            <ion-select [(ngModel)]="venue_name">
                <ion-option *ngFor="let title of venues; let i = index" value="title.venue_id" checked="(i == 0) ? true : null">
                    {{title.venue_name}} 
                </ion-option>
            </ion-select>
        </ion-item>
like image 256
Ammad Nazir Avatar asked Mar 07 '23 12:03

Ammad Nazir


1 Answers

This

value="title.venue_id" checked="(i == 0) ? true : null"

Should be

[value]="title.venue_id" [selected]="i===0"

WORKING DEMO

like image 65
Vivek Doshi Avatar answered Mar 21 '23 03:03

Vivek Doshi