Is there a way to dynamically create “ion-input” items and to use the data. I need to create a
variable number of "ion-input"s based on an array. The creation is actually easy:
<ion-item *ngFor="let att of this.anArray; let idx = index">
<ion-label color="primary">{{att[0]}}</ion-label>
<ion-input *ngIf="att[1] == 'string'" [(ngModel)]="this.modelNames[idx]" text-right value=""></ion-input>
<ion-datetime *ngIf="att[1] == 'year'" displayFormat="YYYY" [(ngModel)]="this.modelNames[idx]"></ion-datetime>
</ion-item>
modelNames[idx] are unique names. They correpondent with “anArray”.But how can i pass the data of the dynamically created formular-items to a function. Normally i would do something like that:
<button ion-button full (click)="goTo(aModel, anotherModel)">let's go</button>
but as you can see, i can’t do this in this case. Maybe i can call every time a function, when something is changed with “ionChange”, and fill some array and uses it later ? Is there a way to perform this task elegantly ?