0

我有一个我正在数据绑定的对象数组 -

$scope.records = [
    {field: "Full Name", value: "Joe Hanigan", isVisible: true},
    {field: "Age", value: "52 Years", isVisible: true},
    {field: "Diagnosis", value: "Common Cold", isVisible: true},
    {field: "Hospital Elum", value: "Alpha Lopus Epsum", isVisible: false},
    {field: "Hospital Code", value: "CKD34-23", isVisible: false}
  ];

我只是将“字段”和“isVisible”显示为复选框。当用户选中/取消选中浏览器中的框时,我想切换“isVisisble”的值。

我怎么做?

4

1 回答 1

3

I assume you use your array in a ng-repeat, where you will define an input field of type checkbox. You use ng-model to bind the field to the model:

<div ng-repeat="record in records">
   <input type="checkbox" name="isVisible" ng-model="record.isVisible">
</div>
于 2013-01-12T18:15:37.747 回答