从JavaScript访问TypeScript函数 [英] Access TypeScript functions from JavaScript
本文介绍了从JavaScript访问TypeScript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将TypeScript与jsTree一起使用.如何在绑定的jsTree函数中调用setCurrentNode
函数?
I want to use TypeScript with jsTree. How can I call the setCurrentNode
function in the bound jsTree function?
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访问TypeScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文