vendredi 22 juin 2018

How to make checkbox value checked from an array

I am using ion-checkbox

<ion-list *ngIf = "heirList.length > 0">
  <ion-item *ngFor = "let each of heirList">
    <ion-label>
      <h5> </h5>
      <h5 clear item-end class="text-blue badge-alert"> #102</h5>
    </ion-label>
    <ion-checkbox  class="selectlist" (ionChange) = "addHeir(each)"></ion-checkbox>
  </ion-item>
</ion-list>

addHeir(each) is checking if the element is present in another array if its present it removes it else it adds that element in that array, everything is working fine till now but if I come back to that page it doesn't show the checkbox checked.

addHeir(value) function is below :

addHeir(value) {
    let index = tempArray.indexOf(value);
    if (index != -1) {
      tempArray.splice(index, 1);
    }
    else {
      tempArray.push(value);
    }
    console.log(tempArray.value);
  }




Aucun commentaire:

Enregistrer un commentaire