如何使用Angular 5在按钮单击上调用多种方法? [英] How to call multiple methods on a button click using Angular 5?

查看:83
本文介绍了如何使用Angular 5在按钮单击上调用多种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用角度5并面临问题.我想提交(单击)事件并一一调用两种或多种方法.请给我一个主意或解决方案,以便我可以提交(单击)事件并调用两个或多个方法.

i am using angular 5 and facing a problem. i want to submit (click) event and call two or multiple method one bye one. Please give me idea or solution so that i can submit a (click) event and call two or multiple method.

例如

.html文件

   <button (click)="abc(); bcde()"></button>

.ts文件

  first method  
  abc(){}

  second method method
  bcde(){}

这是执行此操作的正确方法.请建议我,并帮助我解决这个问题

is this a right way to do this. Please suggest me and help me to solve this

推荐答案

<button (click)="callall()"></button>

创建一个函数并在其中调用所有函数

make one function and call all the function in that

功能1

abc(){}

功能2

bcde(){}

在通用函数中都调用

 callall(){

        this.abc()
        this.bcde() 
}

这篇关于如何使用Angular 5在按钮单击上调用多种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆