lundi 30 novembre 2015

ionic local storage and checkbox

I have created a checkbox in a modal: but when ever I close and reopen the modal, the items that were checked are not shown as checked. here are my codes

<div class="list">
 <ion-checkbox ng-repeat="thema in themen track by $index"
   type="checkbox"
   id="{{thema.id}}"
   ng-model="thema.checked"
   ng-checked="thema.checked">
   {{ thema.name }}
 </ion-checkbox>
</div>

and in the js file I have added

$scope.openModal = function() {
 $scope.modal.show();
  $scope.themen = [
   { name: 'something', id: 1 },
   //some other objects
   ];
};
  $scope.closeModal = function() {
    $scope.updateThemaLocalStorage = function ($index) {
       $window.localStorage.setItem( $index, $scope.themen[$index].checked );
   };
    $scope.modal.hide();
  };

also in gulp watch I recive error "$index" is defined but never used no-unused-vars




Aucun commentaire:

Enregistrer un commentaire