Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
How to detect onfocus and blur event of ion-searchbar in ionic2?

I'm now using ionic2 to build an app. I want to detect when the searchbar input get focus and when it blur so that I can hide or show some components according to the current status. (For example, show some suggestions when the user clicks this searchbar.)

This is my code:

<ion-searchbar #searchbar [(ngModel)]="searchInput"></ion-searchbar>

However, I found that this component seems don't have these two events.I have tried to add an event listener like this, but it didn't work:

<ion-searchbar #searchbar [(ngModel)]="searchInput" (focus)="searchBarOnFocus()"></ion-searchbar>

So can I implement this feature in some other ways?

Thanks in advance!


There are two documents for ion-searchbar: component document & api document

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

To catch focus / blur events on searchbar you should use (ionFocus) and (ionBlur) instead of Angular's (focus) and (blur). Works like a charm for me!

<ion-searchbar #searchbar placeholder="Type an address" showCancelButton
               (ionBlur)="checkBlur()"
               (ionFocus)="checkFocus()"></ion-searchbar>
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda