I am trying to add additional ion-inputs with a button.
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?