复选框值是否未更新?

时间:2017-10-24 10:58:47

标签: angularjs checkbox

这是一个问题。当我检查所有,所有复选框都设置为true但是如果有一些记录,我取消选中其中一个记录,则应取消选中所有复选框。它在plunker工作但不在我的工作空间中任何原因?这是plunker url https://plnkr.co/edit/9JeIuP1jC5hOG5hTpSZV?p=preview

            <div class="row">                                 
            <div class="col-md-4 col-sm-4 col-xs-4">
          <label>
            <input type="checkbox" ng-click="isAllRecordSelected()"
                    ng-
           model="isAllSelectedForSMS">All{{isAllSelectedForSMS}}
          </label>
    </div>

    <div class="col-md-4 col-sm-4 col-xs-4"> Mobile</div>
    <div class="col-md-2 col-sm-2 col-xs-2">Name</div>
  </div>
  <div class ="row"
  ng-repeat="friend in friends">

    <div class="col-md-4 col-sm-4 col-xs-4">
      <label> <input type="checkbox" 
         ng-model="friend.selected"
        ng-change="userSelectedToggle()">
      </label>
    </div>
     <div class="col-md-4 col-sm-4 col-xs-4"> {{friend.mobile}}</div>
     <div class="col-md-2 col-sm-2 col-xs-2">{{friend.name}}</div>
  </div>

1 个答案:

答案 0 :(得分:-1)

只需更正你的HTML

<input type="checkbox" ng-click="isAllRecordSelected()"
                    ng-model="isAllSelectedForSMS">All{{isAllSelectedForSMS}}
          </label>

ngmodel替换为ng-model