localStorage for loop of informations

hi everyone,
I’m trying to store informations from loops. I got a list of toggle checkbox like this : http://image.noelshack.com/fichiers/2016/47/1479933982-togglebuttom.png
I want to check the toggle checkbox when i got informations stored and the toggle still on and the same when I delete the informations stored i when keep the toogle checkbox off. Actually when I check the toggle I got informations from one toggle and all the toggle are checked.
Here is my app.js :
$scope.favorite = {};

// Loads on page load/controller load
$scope.favorite["checked"] = localStorage.getItem("favorites");

// If never set
if($scope.favorite.checked == null) {
$scope.favorite.checked = true;

// Save
$scope.favoriteChange = function() {
localStorage.setItem("favorites", $scope.favorite.checked);
  $scope.addidMatch = function(infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam) {
$i = $i +1
$localStorage[$i] = {
  infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam

And my html code :

<label class="toggle" ng-model="infoTeamCtrl" ng-click="addidMatch(match.data.fixtures[$index].homeTeamName, match.data.fixtures[$index].result.goalsHomeTeam, match.data.fixtures[$index].result.goalsAwayTeam, match.data.fixtures[$index].awayTeamName)">
  <input type="checkbox" ng-model="favorite.checked" ng-change="favoriteChange()" > 
  <div class="track">
   <div class="handle"></div>

I store all informations in a loop track by $index
thank a lot.

That doesn’t look like Ionic 2 to me.

1 Like