我必须为我的代码使用单个复选框

我的doc.ejs

<tr ng-repeat="folder_l in folderlist | orderBy:created_date" >
   <td>
      <div class="permit">
         <input class="chkbtn move_check" type="checkbox" id="movecheck{{folder_l._id}}" name="movecheck" value="{{folder_l._id}}" ng-model="checkfolder" ng-click="updateSelection($index, folderlist)" />
         <label class="chklabel" for="movecheck{{folder_l._id}}"></label>{{checkfolder}}
      </div>
   </td>
</tr>


app.js:

$scope.updateSelection = function(position, entities) {
  angular.forEach(entities, function(subscription, index) {
         console.log('position')

     console.log(parseInt(position))
         console.log('index')

    console.log(parseInt(index))

          $scope.checkfolder;

        if (parseInt(position) == parseInt(index)) {
      console.log("Equal")
     $scope.checkfolder = true;
    }
    else{
      $scope.checkfolder = false;
    }
  });
}


我搜索了很多链接,但我尝试了,但我的代码却无济于事,即使我尝试了jquery click,但click函数仍未调用。

更新
我的JSON

{
    "_id" : *****,
    "__v" : 0,
    "folder_name" : "Music",
    "status" : "Y",
    "created_date" : ISODate("2017-12-29T10:50:31.171Z"),
    "updated_date" : ISODate("2017-12-29T10:50:31.171Z")
}

最佳答案

HTML:

<tr ng-repeat="folder_l in folderlist | orderBy:created_date" >
   <td>
      <div class="permit">
         <input class="chkbtn move_check" type="checkbox" id="movecheck{{folder_l._id}}" name="movecheck" value="{{folder_l._id}}" ng-model="folder_l.checkfolder" ng-click="updateSelection($index, folderlist)" ng-checked="{{folder_l.checkfolder}}" />
         <label class="chklabel" for="movecheck{{folder_l._id}}"></label>{{folder_l.checkfolder}}
      </div>
   </td>
</tr>


JS

$scope.updateSelection = function(position, entities) {
    angular.forEach(entities, function(subscription, index) {
        if (parseInt(position) == parseInt(index)) {
          subscription.checkfolder = true;
        } else {
            subscription.checkfolder = false;
        }
    });
}

09-17 14:31