如何在 Ionic 框架中使用 Checkbox Item?

How to use Checkbox Item in Ionic framework?

我正在使用 Ionic 框架开发移动应用程序。我不知道如何列出哪些检查项目?我尝试了很多方法

谁能帮我解决这个问题?

例如我的复选框部分代码:

>    <ul class="list" ng-repeat="item in TreatmentsSpa">
>       <li class="item item-checkbox">
>         <label class="checkbox">
>           <input type="checkbox">
>         </label>
>       {{item.Name}}
>       </li>

TreatmentSpa 是 JSON 来自 Webapi

我想制作一个列表,其中包含选中项目的名称。

可能这对你有帮助。我在 运行 时间设置了 ng-model (treatment.selected)。

<ion-view view-title="films" ng-controller="TreatmentSpaController">     <ion-content class="padding">
 <div class="item-accordion"
      ng-repeat="treatment in TreatmentSpa track by $index">
   <ion-item class="item item-checkbox">
     <label class="checkbox">
       <input type="checkbox" ng-model="treatment.selected" ng-change="updateTreatmentSpa(treatment)">
     </label>
     {{treatment.name}}
   </ion-item>
 </div>   </ion-content>

控制器:

.controller('TreatmentSpaController', function($scope,$http ) {
$scope.treatmentSpaCheckedItems = [];
$scope.TreatmentSpa = [
  {name:'One'},
  {name:'Two'},
  {name:'Three'},
  {name:'Four'},
  {name:'Five'}
];

$scope.updateTreatmentSpa = function(treatment){
  console.log(' new name  :'+treatment.name);
  if(treatment.selected){
    $scope.treatmentSpaCheckedItems.push(treatment.name);
  }else{
 $scope.treatmentSpaCheckedItems.splice($scope.treatmentSpaCheckedItems.indexOf(treatment.name), 1);
  }
   console.log('checked TreatmentSpa:'+$scope.treatmentSpaCheckedItems);
};});