ng-show / ng-hide在引导程序表事件中不起作用

时间:2016-05-19 10:20:33

标签: angularjs bootstrap-table

当我在bootstrap表事件中设置表达式变量时,我遇到了ng-show / ng-hide的问题。

这是一个html代码片段

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" title="Raum löschen" ng-show="rowsselected"><span class="glyphicon glyphicon-trash"/></button>

<table class="table" id="rooms-table" bs-table-control="bsTableControl"></table>

这里是JS代码

$scope.rowsselected = false;
$scope.checkedRows = [];


var checkRow = function(row, $element) {
  $scope.checkedRows.push({id: row.id});
  $scope.rowsselected = true;
}

var uncheckRow = function(row, $element) {
  var rows = $scope.checkedRows;
  $.each(rows, function(index, value) {
    if (value && value.id === row.id) {
      $scope.checkedRows.splice(index, 1);
    }
  });
  if($scope.checkedRows.length == 0)
  {
    $scope.rowsselected = false;
  }
}

$scope.bsTableControl = {
  options: {
    url: "./json/data.json",
    cache: false,
    height: 710,
    striped: true,
    hover: true,
    pagination: false,
    pageSize: 20,
    pageList: [5, 10, 25, 50, 100, 200],
    search: true,
    showRefresh: false,
    minimumCountColumns: 2,
    clickToSelect: false,
    showToggle: true,
    maintainSelected: true,
    columns: [{
      field: 'state',
      checkbox: true
    }, {
      field: 'name',
      title: 'Name',
      align: 'left',
      sortable: true
    }],
    onCheck: checkRow,
    onUncheck: uncheckRow
  }
};

如果我在ng-click功能中设置行选择它可以正常工作。有什么想法吗?

0 个答案:

没有答案