Sampath
Sampath

Reputation: 65870

Cannot set selected attribute for dynamically loaded Ionic2 ion-select

I need to load <ion-select> dynamically.It is working fine.Now I need to set default selection.I have used selected attribute for that.But it is not working.Can you tell me why?

Here is the Plunker

app/home.page.html

 <ion-item>
      <ion-label>Donation</ion-label>
      <ion-select>
        <ion-option *ngFor="let date of donationDates" value="{{date.donationdate}}" selected="date.isChecked">
          {{date.donationdate}}</ion-option>
      </ion-select>
    </ion-item>

app/home.page.ts

export class HomePage {
  donationDates:any=[];

  constructor(public navController: NavController) { 
      this.donationDates = [
       {
          id: null,
          donationid: "2",
          donationdate: "2017-03-12",
          datedescription: "Vad Bij",
          isChecked:true
      },
      {
        id: null,
       donationid: "2",
       donationdate: "2017-03-19",
       datedescription: "Sud satam",
       isChecked:false
     }]
  }

}

Upvotes: 1

Views: 345

Answers (1)

AVJT82
AVJT82

Reputation: 73357

Use:

[selected]="date.isChecked"

Your Forked Plunker

Upvotes: 2

Related Questions