<分区>
我在我的 Controller 中定义了一个 jquery ui-grid 组件,它的缩小示例如下所示:
class myController {
constructor($scope) {
this.$scope = $scope;
this.Grid = {
selectionSettings:{
clientHandler:function(key,object,data){
console.log(key);
console.log(object);
console.log(data);
console.log(this);
return data;
//the scope of this function is different from the controller scope.
}
}
}
receiver(data){
doSomething(data);
}
...
想法是当我在网格中选择一个条目时,clientHandler 中的函数被触发。然后,我希望此函数将该数据传递给此类中的接收函数。
但是由于这个 clientHandler
函数和 receiver()
在不同的范围内,我不能直接使用 this
关键字。
stackoverflow 上的其他答案建议使用 $scope
对象来完成相同的任务,但我无法这样做。
clientHandler
函数调用 receiver()
需要什么?
热切欢迎任何指导。谢谢