I have a generated input list with some data that changes to each user, the data comes as an object and the list is created from the properties of this object. Since this data changes to each user, I can never know the quantity of properties neither the name of the properties. In this input list the user can change the value of the properties and then it should return it as a new object named returnValues
.
My problem is that the values are never returned, the object returned is always empty.
html
<ion-content>
<ion-list *ngFor="let key of objectKeys(properties)">
<ion-item>
<ion-label position="stacked">{{key}}</ion-label>
<ion-input type="text" [(ngModel)]="returnValues.key" [ngModelOptions]="{standalone: true}">{{properties[key]}}</ion-input>
</ion-item>
</ion-list>
</ion-content>
...
<ion-button (click)="save()">Save</ion-button>
ts
private objectKeys = Object.keys;
private returnValues: Object = {};
...
save() {
console.log(this.returnValues);
}
- I tried to put the returned object in the constructor, as suggested here, but to no avail.
- I tried to create know empty properties to know input objects to check if they are changed, but they are also not.
- I thought about using forms, but from the documentation I saw that it is necessary to assign names to each input, which I can’t.
1 post - 1 participant