javascript - 无法在 ngHandsontable 中设置未定义的属性 'datarows'

标签 javascript angularjs angularjs-directive handsontable

我对ngHandsontable有疑问组件:我收到此错误:

Cannot set property 'datarows' of undefined

尝试初始化表时。我正在使用的代码是这样的:

<hot-table rowHeaders="true" startRows= "7" manualColumnResize="true" datarows="td"
                           settings="{  colWidths: [150, 150, 150, 150,150], colHeaders: colHeaders, contextMenu: ['row_above', 'row_below', 'remove_row'], afterChange: afterChange }">
  <hot-column data="COLUMN_1" title="'COLUMN_1'"></hot-column>
  <hot-column data="COLUMN_2" title="'COLUMN_2'"></hot-column>
  <hot-column data="COLUMN_3" title="'COLUMN_3'"></hot-column>
  <hot-column data="COLUMN_4" title="'COLUMN_4'"></hot-column>
  <hot-column data="COLUMN_5" title="'COLUMN_5'"></hot-column>
</hot-table>

在 Controller 中:

$scope.td = [{
    'COLUMN_1': ''
}];

请注意,settings 对象具有一些我的 Controller 中不存在的默认属性(colHeadersafterChange)。我几乎尝试了一切:我删除了设置属性、数据行属性、所有属性!错误消息没有任何变化。

查看 ngHandsontable 的源代码,我发现这是有问题的行:

angular.forEach(bindingsKeys, function(key) {
  var mode = _this.scope[key].charAt(0);

  _this.$$isolateBindings[key] = {
    attrName: _this.scope[key].length > 1 ? _this.scope[key].substr(1, _this.scope[key].length) : key,
    collection: key === 'datarows',
    mode: mode,
    optional: false
  };
});

错误在于 _this.$$isolateBindings[key] 未定义 _this.$$isolateBindings

我对此一无所知,我发现我的案例中的配置与指令的示例略有不同。

我实际上使用的是 0.9.0 版本,以及 Handsontable 0.23.0(免费)和 AngularJS 1.2.28。

我在这里缺少什么?

谢谢。

最佳答案

我刚刚发现这个:

https://github.com/handsontable/ngHandsontable/blob/develop/index.html#L69

Note: ngHandsontable supports angular in version 1.3 and greater.

这是因为您使用的是较旧的 Angular 版本。我刚刚升级到 Angular 1.5.8,然后它就可以工作了。

关于javascript - 无法在 ngHandsontable 中设置未定义的属性 'datarows',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37798221/

相关文章:

javascript - 如何将事件绑定(bind)到 sessionStorage?

angularjs - 注意在指令中第二次更改范围时不触发

angularjs - Angular : How to change the data type using $formatters and $parsers?

javascript - 什么可能导致 Angular 无法正常渲染?

javascript - 根据搜索字符串结果切换模型

angularjs - 如何在 Angular JS 中迭代 json 对象?

javascript - 每个月特定日期的剩余天数

javascript - 在 Webpack 中获取 "Cannot resolve module ' aws-sdk' ,'child_process' ,'net' "in/node_modules/watchpack

javascript - 如何加载谷歌地图作为回调?

angularjs - Angular 谷歌地图标记未显示