Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!