【发布时间】:2013-08-15 05:09:33
【问题描述】:
我想将 TypeScript 与 jsTree 一起使用。如何在绑定的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
}
}
【问题讨论】:
-
.bind("select_node.jstree", function (e, data) { this.setCurrentNode(data); });?function不会捕获this,但箭头函数会捕获this。
标签: javascript typescript jstree