如何在外部隐藏/显示ng-grid列?

Ano*_*lip 6 angularjs ng-grid

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

我尝试过这个,但它不起作用

$scope.gridOptions.$gridScope.columns[0].toggleVisible()
Run Code Online (Sandbox Code Playgroud)

Aar*_*k71 10

尝试使用ng-click指令

你的HTML按钮看起来像这样

<input type="button" ng-click="toggleCol(0)" />
Run Code Online (Sandbox Code Playgroud)

你的js喜欢这个

var app = angular.module('myCoolGridApp', ['ngGrid']);
app.controller('MyCtrl', function ($scope) {
    $scope.toggleCol= function(i) {
       $scope.gridOptions.$gridScope.columns[i].toggleVisible()
    }
}
Run Code Online (Sandbox Code Playgroud)