我想将 TypeScript 与 jsTree 一起使用。如何在绑定(bind)的jsTree函数中调用setCurrentNode
函数?
class MyController {
thescope: any;
static $inject = ['$scope'];
constructor($scope) {
$scope.vm = this;
this.thescope = $scope;
(<any>$("#demo2")).jstree({
.bind("select_node.jstree", function (e, data) {
// how can I call setCurrentNode(data) here?
}
});
}
setCurrentNode(node: any): any {
... // do Stuff in this typescript function
}
}
最佳答案
解决方案:
(<any>$("#demo2")).jstree({
.bind("select_node.jstree", this.setCurrentNode.bind(this) )
}
public setCurrentNode(e:any,data: any): any {
...
}
关于javascript - 从 JavaScript 访问 TypeScript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18228723/