Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 5 - Autocomplete value gives only typed letters #5678

Closed
troncomputers opened this issue Feb 19, 2018 · 1 comment
Closed

Angular 5 - Autocomplete value gives only typed letters #5678

troncomputers opened this issue Feb 19, 2018 · 1 comment

Comments

@troncomputers
Copy link

In my autocomplete I have data from my API. It works fine, but when I select one it gives me only letters that I typed not whole selected item.

    const autoComplete = document.querySelector('.autocomplete');
    this.http.get('http://myapi.com/api/customers')
    .subscribe((result:any[]) => {
      let customers = {};
      for(var i=0;i<result.length;i++)
      {
        customers[result[i].Kod] = null;
      }
      M.Autocomplete.init(autoComplete, {
        data : customers
    });
    });

Is that a normal behavior?

@troncomputers
Copy link
Author

Fixed with adding a change event
<input type="text" id="autocomplete_kontrahenci" class="autocomplete" (change)="selectItem($event)">

selectItem(event:any)
{
   this.Variable = event.target.value;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant