我们如何在 Angular5 中的(点击)事件上添加两个函数

How can we add two function on (click) event in Angular5

我想在(单击)按钮时调用 2 个方法。 Angular5有什么办法吗

你可以简单地这样做

<div (click)="methodt1(); method2()"></div>

你有两个选择 -

Option 1 : Inline call

点击以逗号分隔

 <input (click)="fun1(); fun2()")/>

Option 2 : Recommended way

您可以在 ts 文件中再写一个函数来调用这两个方法。

html

<input (click)="callMe()")/>

ts

  callMe(){
     fun1();
     fun2();
  }

  fun1(){
   ...
  }

  fun2(){
    ...
  }