Ion-option can't use objects in rc3


#1

I was trying to show a select on some objects:

<ion-select [(ngModel)]="company.form">
    <ion-option *ngFor="let form of forms" [value]="form" [selected]="form.name == company.form.name">{{form.name}}</ion-option>
</ion-select>

The problem was that the actually selected value in the company.form property didn’t showed up when opening the page. I have tried to reproduce it with as short code as I could and I couldn’t make it to work that way either. The only solution is to use ids and “manual” search for the selected objects in the controller and set that into company.form:

  <ion-select [ngModel]="company.form.id" (ngModelChange)="companyFormSelected($event)" okText="Ok" cancelText="Mégsem">
    <ion-option *ngFor="let form of forms" [value]="form.id" [selected]="form.id == company.form.id">{{form.name}}</ion-option>
  </ion-select>

  companyFormSelected(newform) {
    let selectedForm = this.forms.find((f)=>{
      return f.id === newform;
    });
    this.company.form=selectedForm;
  }

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45