Having an issue.
Trying to connect a toggle button with a list and use the toggle's id as a key.
//Function for conversion
transform(d)
{
alert(d); //when i put this.id here i have undefined value
return Number(d);
}
<ion-toggle id="0" name="toggle1" [(ngModel)]="listToggle1[this.id)]"></ion-toggle>
<!--The problem is that "id" is a string and I need an integer key for the list -->
<!--This works but isn't dynamic -->
<ion-toggle id="0" name="toggle1" [(ngModel)]="listToggle1[0]"></ion-toggle>
<!-- I attempted this -->
<ion-toggle id="0" name="toggle1" [(ngModel)]="listToggle1[transform(this.id)]" ></ion-toggle>
<!--I'm using a function to convert the string id to an int value in typescript
But the issue lies in transform(this.id) where this.id is undefined-->
<!--This works but again not dynamic -->
<ion-toggle id="0" name="toggle1" [(ngModel)]="listToggle1[transform('0')]" ></ion-toggle>
Hoping for any assistance on this matter.