如何使用 Angular 5 在单击按钮时调用多个方法? [英] How to call multiple methods on a button click using Angular 5?
本文介绍了如何使用 Angular 5 在单击按钮时调用多个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 angular 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
功能一
abc(){}
功能 2
bcde(){}
在公共函数中调用两者
callall(){
this.abc()
this.bcde()
}
这篇关于如何使用 Angular 5 在单击按钮时调用多个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文