I encountered a problem while working on an ionic app. I needed to have individual control over toggle switches, but my current code toggles all switches at once whenever one switch is tapped. Is there a way to fix this and manage each toggle switch separately?
app.ts file
toggleSwitch(switchName) {
console.log(switchName + ' toggled');
console.log('Toggle value=' + this.toggleValue);
}
app.html file
<ion-row>
<ion-col>
<ion-list>
<ion-item *ngFor="let switch of switches">
<ion-label>Switch Name: {{switch.Switch.name}}</ion-label>
<ion-toggle [(ngModel)]="toggleValue" (ionChange)="toggleSwitch(switch.Switch.name)"></ion-toggle>
</ion-item>
</ion-list>
</ion-col>
</ion-row>