Set checkbox checked value

Hello everyone,

Iam doing a simple app using a list of checkboxes.
Here is my template:

<ion-list>
     <ion-item ng-repeat="configList in configLists">
            <label class="checkbox">
              <input type="checkbox" checked="configList.selected" ng-click="addToApiList(configList.name)">
          	</label>
            {{configList.name}}
    </ion-item>
    </ion-list>

So this list is ok and the names are ok, but since i try to set the ‘checked’ value by hand, it turns that all my checkboxes are true.

I tried this, and this also gives me all checkbox true:

<input type="checkbox" checked="" ng-click="addToApiList(configList.name)">

Maybe Iam doing something wrong, but it seem I can not set the checked value.

How can I do to initialise my ‘checked’ values when i create my list ?

Thank you

Take a look at our checkbox example, see if there is anything off from that.

1 Like

Hello, in my case I resolve this issue in my codes with a map function.

on my controller i have this:

  $scope.configLists.map(function(configList){
    interest.checked = $scope.configListChecklist.includes(configList.id);
  });

where configListChecklist is my array with checked values.

NOTE: I know this was posted in 2k14, but I got this today when facing that issue, so, hope it help :wink:

1 Like