首页 > 解决方案 > 如何在按钮单击时添加新功能

问题描述

我在 td 中有一个带有条件的 ngClass,如下所示:

<tr>
    <td [ngClass]="{active: !show, inactive: show}"></td>
    <td></td>
</tr>

这个 ngClass 在按钮点击功能上被激活,如下所示:

<button type="reset" class="btn btn-primary" (click)="show = !show">Play</button>

现在我必须在此按钮单击上添加功能。怎么能加呢?

标签: angularangular6

解决方案


使用;向事件添加多个功能。

(click)="show = !show; yourFunction()"

推荐阅读