在另一个函数中访问$ event值

时间:2017-11-22 10:34:14

标签: angular

我是角色和javascript的新手。

我从(cellValueChanged)="enableCancelApplyButton($event)"获得了真假值。

我想在enableCancelApplyButton($event)函数中使用trashRowForDetailedEditFlowRules获得的值。

我该怎么办?请帮忙



public trashRowForDetailedEditFlowRules(e: any) {
  let rowIndex = e.rowIndex;
  if (rowIndex == 1) {
    this.showDetailCancelFlag = true;
    this.showApplyButton = true;
  }

}

private enableCancelApplyButton(flag: boolean) {
  if (flag === true) {
    this.showDetailCancelFlag = false;
    this.showApplyButton = false;
  }
}

<inline-edit-grid [gridParams]="editDetailGridParams" (cellValueChanged)="enableCancelApplyButton($event)" (rowClicked)="onDetailEditRowClicked($event)" (copyClicked)="onCopyClicked($event)" (trashClicked)="trashRowForDetailedEditFlowRules($event)" (editClicked)="editCellUpdate($event)"
  class="grid-top session-grid" #editDetailGrid>
</inline-edit-grid>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

只需在enableCancelApplyButton中调用trashRowForDetailedEditFlowRules并将$ event作为参数传递给trashRowForDetailedEditFlowRules(e)。

答案 1 :(得分:0)

不确定这是更好的选择,但您可以轻松创建一个私有属性,您可以在其中传递值es:

private sharedBool: boolean = false;

    public trashRowForDetailedEditFlowRules(e: any) {
   //here you can access the sharedBool
  let rowIndex = e.rowIndex;
  if (rowIndex == 1) {
    this.showDetailCancelFlag = true;
    this.showApplyButton = true;
  }

}

private enableCancelApplyButton(event) {
  this.sharedBool = event;
  if (event === true) {
    this.showDetailCancelFlag = false;
    this.showApplyButton = false;
  }
}

希望它可以提供帮助