Encountering an issue with ionic toggles where changing any toggle affects only the last if statement below in local storage.
Here is the list of toggles...
$scope.settingsList = [
{ text: "GBP", checked: gbpON },
{ text: "USD", checked: usdON },
{ text: "EURO", checked: euroON },
{ text: "AUD", checked: audON },
{ text: "CAD", checked: cadON },
{ text: "YEN", checked: yenON }
];
This is the HTML...
<div class="list">
<ion-toggle ng-repeat="item in settingsList"
ng-model="item.checked"
ng-checked="item.checked"
ng-change="toggleONOFF({{item.text}})"
toggle-class="toggle-royal">
{{item.text}}
</ion-toggle>
</div>
and this is what happens when you click the toggle...
$scope.toggleONOFF = function($var) {
// GBP is toggled
if ($var = "GBP") {
if (localStorage.getItem("gbpON") == "true") {
localStorage.setItem("gbpON", false);
} else {
localStorage.setItem("gbpON", true);
}
};
// USD is toggled
if ($var = "USD") {
if (localStorage.getItem("usdON") == "true") {
localStorage.setItem("usdON", false);
} else {
localStorage.setItem("usdON", true);
}
};
// EURO is toggled
if ($var = "EURO") {
if (localStorage.getItem("euroON") == "true") {
localStorage.setItem("euroON", false);
} else {
localStorage.setItem("euroON", true);
}
}
// AUD is toggled
if ($var = "AUD") {
if (localStorage.getItem("audON") == "true") {
localStorage.setItem("audON", false);
} else {
localStorage.setItem("audON", true);
}
}
// CAD is toggled
if ($var = "CAD") {
if (localStorage.getItem("cadON") == "true") {
localStorage.setItem("cadON", false);
} else {
localStorage.setItem("cadON", true);
}
}
// YEN is toggled
if ($var = "YEN") {
if (localStorage.getItem("yenON") == "true") {
localStorage.setItem("yenON", false);
} else {
localStorage.setItem("yenON", true);
}
}
}
The problem I'm facing is that regardless of which toggle is pressed, it only changes the value for yen in local storage rather than the corresponding one. For example, toggleONOFF(GBP)