如何获取 AngularJS ngHandsontable 的句柄

How to get handle to the AngularJS ngHandsontable

我有一个 AngularJS 项目,我有一个在 HTML 代码中定义的 ngHandsontable。我正在尝试获取 table 的句柄以便将 'afterChange' 挂钩附加到它。如何获取 table?

的句柄

代码示例:

HTML

<div id="hoTableContainer">
<hot-table id="handsontableId" datarows="myData">
    <hot-column data="name" title="'Name'"></hot-column>
    <hot-column data="group" title="'Group'" readOnly></hot-column>
    <hot-column data="unit" title="'Unit'"></hot-column>
</hot-table>
</div>

Javascript

document.getElementById('handsontableId').addHook(...)
// Also tried:
var hotInstance = $("#hoTableContainer").handsontable('getInstance'); 

您正在寻找的活动是:

您所要做的就是在您的控制器中定义一个设置对象:

$scope.myAfterChangeHandler = function () {
    // your code
};

$scope.mySettings = {
     afterChange: $scope.myAfterChangeHandler
};

然后在您的 HTML 中引用该设置对象

<hot-table id="handsontableId" datarows="myData" settings="mySettings">