How to call multiple methods on a button click using Angular 5?

余生长醉 提交于 2020-03-18 11:14:18

问题


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.

such as

.html file

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

.ts file

  first method  
  abc(){}

  second method method
  bcde(){}

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


回答1:


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

make one function and call all the function in that

function 1

abc(){}

function 2

bcde(){}

call both in common function

 callall(){

        this.abc()
        this.bcde() 
}



回答2:


you can also do

<button (click)="[abc(), bcde()]"></button>


来源:https://stackoverflow.com/questions/48317539/how-to-call-multiple-methods-on-a-button-click-using-angular-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!