toggleCollapse(i) {
this.toggles[i] = !this.toggles[i];
return false;
}
我有一个父'tr标签',其中包含一个切换崩溃状态的点击事件。在里面我有一个td标签,它将包含一些内容。我想在点击'td'标签时取消点击事件触发。示例代码:
<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>
答案 0 :(得分:10)
(click)="toggleCollapse(i, $event)"
toggleCollapse(i, event) {
this.toggles[i] = !this.toggles[i];
event.stopPropagation();
}