<ion-option *ngfor> inside <ion-select> error


#1

My object is:


But when i run this template:

<div *ngIf="question.units.length>1">
    <ion-item>
        <ion-select [(ngModel)]="Answers[i]" interface="action-sheet" cancelText="{{'cancel'|translate}}">
            <ion-option *ngFor="let unit of question.units" [value]="unit.UNIT_FACTOR" [selected]="unit.TYPE=='primary'? 'true':'false'">{{unit.TITLE}}</ion-option>
        </ion-select>
    </ion-item>
</div>
<div *ngIf="question.units.length<=1">
    <ion-item>
        {{question.units[0].TITLE}}
    </ion-item>
</div>

It show all item seperated by “,”?
image
And click to chose item, it selected all?


When i tested without *ngFor, it’s worked.
Please help me to correct the template.
Thank you so much.


#2

@zakton5 please help!


#3

@joshmorony, @rapropos please help me to solve this problem


#4

Coud it be that unit_factor is always 1?


#5

yes, two unit.UNIT_FACTOR is 1, so what does it mean?


#6

I think value must be unique in the select. So try to use the index of the array as value.


#7

Thank you, when i remove [value]=“unit.UNIT_FACTOR” it’s work.