如何在特定行上启用点击操作?

时间:2018-11-19 06:08:34

标签: javascript angular html5

<tr class="t-row {{selectedGoalIndex == j?'active-row':''}}" *ngFor="let goalObj of goalsList;let j=index;" (click)="getSelectedGoal(goalObj,j);">
  <td class="t-column" style="width:70%">{{goalObj.goalType.combinedName}}
    <span class="goals-doubletriangle" *ngIf="doubleTriangle==true" (click)="showDoubleTriangleUp(selectedGoal);">
      <img class="goals-icon-up" src="assets/images/doubletriangle.svg" />
    </span>
    <!-- <span class="goals-doubletriangle" *ngIf="doubleTriangle==false" (click)="showDoubleTriangleDown(selectedGoal);">
      <img class="goals-icon-down" src="assets/images/doubletriangle.svg" />
    </span> -->
  </td>
  <td class="t-column align-right" style="width:30%">
    <span class="icon-trash-o goal-delete show-pointer" *ngIf="!(isSuperAdminUser) && isEditable" (click)="deleteGoal(goalObj);"></span>
    <span class="icon-angle-right"></span>
  </td>
</tr>

这是我拥有的代码,我想在双三角图像上启用单击动作,并且在单击doubletriangle下层类后,该行应该位于活动行中(仅在活动行中)。该怎么做?

1 个答案:

答案 0 :(得分:0)

也许这对您有用,但是您需要调整项目代码。

constructor(
    private elem: ElementRef,
    private renderer: Renderer2
) {}

this.naviElem = this.elem.nativeElement.querySelector('.imgclass');

this.renderer.addClass(this.naviElem, 'active');