Yusof Bandar
Yusof Bandar

Reputation: 181

Ionic onfocusout event equivalent

In Ionic v3 there is an equivalent of onfocus called (ionFocus).

For example to check on focus for an ion button it will be:

<button ion-button (ionFocus)="checkFocus()">Click Me</button>

I was wondering if there was an equivalent for onfocusout.


I tired:

 <button ion-button (ionFocusout)="checkFocus()">Click Me</button>

But that did not work.

Many thanks

Upvotes: 3

Views: 13075

Answers (2)

Rajat.r2
Rajat.r2

Reputation: 133

In case of noob 😜 like I was

     <ion-item no-lines>
        <ion-label stacked>My Label</ion-label>
        <ion-input
          type="text"
          placeholder="My place holder..."
          (ionFocus)="setInputFocus()"
          (ionBlur)="unCheckFocus()"
          [(ngModel)]="myInputValue">
        </ion-input>
    </ion-item>

In typeScript file

   setInputFocus() {
      console.log("Input box is active");
   }

  unCheckFocus() {
      console.log("Input box is Deactive");
  }

Upvotes: 0

Mahesh Jadhav
Mahesh Jadhav

Reputation: 1089

A more ionic way can be using ionic's ionBlur event which will fire an event whenever the selected element looses focus (i have used it on input and search bar but not on buttons yet)

  (ionBlur)="checkFocus()"

Upvotes: 4

Related Questions