【问题标题】:AngularJs Checkbox FunctionAngularJs 复选框功能
【发布时间】:2015-11-27 09:23:52
【问题描述】:

我想在复选框的值为真时将背景颜色更改为浅蓝色,并在值为假时将背景颜色更改回正常。

<tr ng-repeat="item in rows | filter:search" ng-class="{'selected':$index == selectedRow}">

我的复选框:

<td><input type="checkbox" ng-click="setClickedRow($index)"></td>

我的功能:

$scope.selected = null;  
$scope.setClickedRow = function(index){  
    $scope.selectedRow = index;
}

【问题讨论】:

    标签: angularjs checkbox


    【解决方案1】:

    这里有一个例子:http://plnkr.co/edit/CHB65fe6Bsd3PdjWjoT4?p=preview

    这是桌子:

    <table style="width:100%">
    <tr ng-repeat="item in rows | filter:search" ng-class="{'selected': item.selected}">
      <td>
        <input type="checkbox" ng-model= "item.selected" ng-click="setClickedRow($index)">
      </td>
    </tr>
    </table>
    

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      • 2014-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多