ng-show 在 handsontable 列中不起作用

ng-show doesn't work in handsontable column

我正在使用 Handsontable 0.34.5 和 AngularJS 1.6.5 以及 ngHandsontable 0.13 包装器。

我需要根据条件隐藏handsontabletable栏

我尝试使用 ng-show 或 ng-hide 指令来执行此操作,但它不起作用。

Handsontable HiddenColumns 0.34.5版本好像不支持插件

代码如下:

<hot-table settings="tableSettings" datarows="items">
    <hot-column ng-show="false" data="id" title="'ID'"></hot-column>   
</hot-table>

这里是 demo.

如何使用 angular 指令隐藏 handsontable?

更新:

目前我正在使用 ng-if 指令。但它有一个我不满意的问题:当条件为真并且列被添加到 table 的末尾时它会重新创建 DOM,而不是它被规定的位置。看看吧here

您可以使用 ng-if 指令隐藏您的列

<hot-table settings="tableSettings" datarows="items">
    <hot-column ng-if="false" data="id" title="'ID'"></hot-column>   
</hot-table>

Demo

要操作列,请避免使用 <hot-column> 指令。而是使用 columns 属性:

<hot-table col-headers="true" 
           datarows="ctrl.data" 
           columns="ctrl.columns">
</hot-table>
this.columns = [
    { data: 'id',    title: 'ID',    readOnly: true  },
    { data: 'name',  title: 'Name',  readOnly: true  },
    { data: 'price', title: 'Price', readOnly: false }
];


var deletedName;  
this.hideName = function() {
    deletedName = this.column.splice(1,1);
};
this.showName = function() {
    this.column.splice(1,0,deletedName);
};