I want to call 2 functions in a single <input type="text" (focusout)=""> based on a condition.
I don't want to use *ngIf else conditions.
Example
component.ts file i have declared 1 variable like
isCall = true;     
functionA(){}
functionB(){}
My component.html file is as follow
<input type="text" (focusout)="">
I want to call these 2 functions based on isCall from (focusout)="" event.
Suppose isCall variable is true then I want to call functionA() else functionB()
How can I call these function based on the condition?
You can call two functions by using ternary operator based on condition.
<input type="text" (focusout)="isCall ? functionA() : functionB() ">
Here is solution on stackblitz
You can use ternary operator ? : and based on condition you can call functionA() or functionB() like below. 
component.html
<input type="text" (focusout)="isCall ?  functionA() : functionB()">
component.ts
 functionA() {
    console.log('HelloA');
  }
   functionB() {
    console.log('HelloB');
  }
Here is solution on stackblitz
Hope this will help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With