6

我正在使用ng-grid 我想在外部按钮单击时隐藏/显示列的位置。

我试过这个,但它不工作

$scope.gridOptions.$gridScope.columns[0].toggleVisible()
4

1 回答 1

10

Try using the ng-click directive

your html button could look like this

<input type="button" ng-click="toggleCol(0)" />

and your js like this

var app = angular.module('myCoolGridApp', ['ngGrid']);
app.controller('MyCtrl', function ($scope) {
    $scope.toggleCol= function(i) {
       $scope.gridOptions.$gridScope.columns[i].toggleVisible()
    }
}
于 2013-09-06T11:48:51.233 回答