Reputation: 93
my html is simple like this
<ion-list>
<ion-item *ngFor="let item of editLists,index as i">
<ion-input [(ngModel)]="editLists[i]"></ion-input>
</ion-item>
</ion-list>
<ion-input [(ngModel)]="foo"></ion-input>
it'ok type words when ion-input outside ngFor; but when inside it will lose focus when i type one word how? many thanks
Upvotes: 2
Views: 334
Reputation: 27333
Use trackBy along with ngFor to avoid re rendering input whenever input changes.
component.html
<ion-list>
<ion-item *ngFor="let item of editLists,index as i;trackBy:trackEditList">
<ion-input [(ngModel)]="editLists[i]"></ion-input>
</ion-item>
</ion-list>
</ion-content>
component.ts
trackEditList(index,item){
return index;
}
Upvotes: 4