I made a list of inputs like this:
<ion-list> <ion-item *ngFor="let item of itemList; let i = index;"> <ion-label stacked primary>An item</ion-label> <ion-input type="text" [(ngModel)]="itemlist[i]"></ion-input> <ion-item> <ion-list>
It works fine functionally, except for one strange, bad thing: Every time I type a character in the input field, it loses focus. So I have to click the input field again to enter the next character. This happens in a browser (ionic serve) and on an iPhone (ionic run). Is there a trick to this I am missing?
(At first I thought it should be [(ngModel)]=“item” but that errors out with “Unhandled Promise rejection: Cannot assign to a reference or variable!”)
It has something to do with the *ngFor, because this does not have a problem:
<ion-list> <ion-item> <ion-label stacked primary>An item</ion-label> <ion-input type="text" [(ngModel)]="itemlist"></ion-input> <ion-item> <ion-list>
I put a plunker together for it http://plnkr.co/edit/tJFPUR?p=preview but unfortunately the plunker doesn’t run at all when I add the ngModel with the array element in the *ngFor.
I am running Ionic 2 RC1.