@DeeM52 wrote:
I am trying to add additional ion-inputs with a button.
Image may be NSFW.
Clik here to view.I am getting this error with the following code below.
EXCEPTION: Error: Uncaught (in promise): Cannot assign to a reference or variable!
In the HTML file
<ion-list> <!-- First attempt with the error --> <!-- EXCEPTION: Error: Uncaught (in promise): Cannot assign to a reference or variable! --> <!-- <ion-item *ngFor="let myItem of myItemsList"> <ion-input [(ngModel)]="myItem" type="text" placeholder="Add an item"></ion-input> </ion-item> <button small light (click)="addItem()" >Add item</button> --> <!-- Second attempt with same variable in all the ion-input --> <ion-item *ngFor="let myItem of myItemsList"> <ion-input [(ngModel)]="anotherItem" type="text" placeholder="Add an item"></ion-input> </ion-item> <button small light (click)="addItem()" >Add item</button> </ion-list>
In the TS file
myItemsList = [ "First item", "Second item", "Third item" ]; addItem() { this.myItemsList.push(""); }
Anyone has an idea on what to do? How to achieve this?
Posts: 1
Participants: 1