Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
Angular 2 NG-Completer calling keyup event twice?

I have a simple element inside my HTML. When a key is released inside of it, a call is made to a method that writes to the console. The issue I'm having is that the console is being written to twice. So I'm assuming that (keyup) is being hit twice, am I right?

Here is my ng2=completer:

<ng2-completer #from [(ngModel)]="fromSearch" [datasource]="airportCodeList" [minSearchLength]="0" (keyup)="onKey()"></ng2-completer>

Below is the onKey method being called:

onKey(entry: string) {
  console.log("Key Pressed"); 
}

Any help would be much appreciated.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Try to put ng2-completer into a div and move (keyup)="onKey()" to the div like:

<div (keyup)="onKey()">
  <ng2-completer #from [(ngModel)]="fromSearch" 
 [datasource]="airportCodeList" [minSearchLength]="0"></ng2-completer>
</div>
over 4 years ago · Santiago Trujillo Denunciar

0

Yes. This is because the author of the component handled the keyUp event twice. Evidences :

Source Code Link enter image description here

Also, he handles the keyUp event in the directive

Source Code Link enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda