Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call multiple methods on a button click using 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.

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

like image 925
raihan Avatar asked Jan 18 '18 09:01

raihan


People also ask

Can click have two functions?

Yes, you can call two JS Function on one onClick. Use semicolon (';') between both the functions.


2 Answers

you can also do

<button (click)="[abc(), bcde()]"></button>
like image 101
shahidfoy Avatar answered Oct 10 '22 21:10

shahidfoy


<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() 
}
like image 39
Arun Kumaresh Avatar answered Oct 10 '22 21:10

Arun Kumaresh