Angular 4、使用ng2-smart的回调'onComponentInitFunction'函数时'this'未定义table

Angular 4 , 'this' is undefined when using callback 'onComponentInitFunction' function of ng2-smart table

我在我的组件中使用 ng2-smart-table。

我正在尝试调用父组件的 approveTheOrder() 方法,但我无法获取父组件的对象 class

下面是片段

{
  title: "Actions",
  type: "custom",
  renderComponent: ActionRenderComponent,
  onComponentInitFunction(instance) {
    instance.actionEmitter.subscribe(row => {
      if(row == CONSTANT.STATUS_APPROVE){
        //here 'row' value is from childComponent-ActionRenderComponent,which I am able to get easily in parentComponet 
       this.approveTheOrder(instance.rowData.id); // here this is undefined, 

      }
      if(row == CONSTANT.STATUS_REJECT){
        this.rejectOrder();//this is undefined
      }
      if(row == CONSTANT.STATUS_PENDING){
        this.pendingOrder(); // this is undefined
      }
    });
  },

  filter: false
};

有谁知道如何在下面的 onComponentInitFunction() 中获取 'this' 吗?

下面是我遇到的错误的图像。

我也试过用'bind'功能没有达到目的,谁能指导一下,我真的卡在这了。

编辑 1 请注意,我能够从 ParentComponent 中的 ChildComponent 获取事件,但这里的问题特定于 ng2-smart-table零件。

为了从 ChildComponent 获取值,我正在尝试使用 ng2-smart 的内置回调函数 onComponentInitFunction(instance) -table 分量

语法如下:

{
  onComponentInitFunction(instance) {
    ...

将转换为函数表达式:

{
  onComponentInitFunction: function(instance) {
    ...

你应该使用箭头函数来保留 this:

onComponentInitFunction: (instance) => {