3
toggleCollapse(i) {
  this.toggles[i] = !this.toggles[i];
  return false;
}

I have a parent 'tr tag' with a click event which toggle collapse states. Inside i have a td tag which will hold some content. I want to cancel the click event trigging when clicking on 'the td' tag. Example code:

<tr *ngFor="let record of records; let i = index" class="pointer" (click)="toggleCollapse(i)">
    <td>{{record.id}}</td>
    <td>{{record.skapad}}</td>
    <td>{{record.status}}</td>
    <td (click)="cancel here">
      <pre *ngIf="!toggles[i]" class="wrap-whitespaces pointer-text">{{getShortContent(record.content)}}</pre>
      <pre *ngIf="toggles[i]" class="wrap-whitespaces pointer-text">{{record.content}}</pre>
    </td>
  </tr>
Emanuel Weinsjö
  • 451
  • 1
  • 5
  • 15

1 Answers1

10
(click)="toggleCollapse(i, $event)"
toggleCollapse(i, event) {
  this.toggles[i] = !this.toggles[i];
  event.stopPropagation();
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567