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

Autocomplete after x characters #25

Closed
thari119 opened this issue Dec 10, 2018 · 3 comments
Closed

Autocomplete after x characters #25

thari119 opened this issue Dec 10, 2018 · 3 comments

Comments

@thari119
Copy link

anyway we can trigger the autocomplete after x number of characters to optimise the google api call outs?

@skynet2
Copy link
Owner

skynet2 commented Dec 11, 2018

Hi @thari119 ,

There is a feature request on google for that https://issuetracker.google.com/issues/35823678

But looks like it`s closed as obsolete, because of new session-based billing for Places autocomplete. (last comment)

@skynet2 skynet2 closed this as completed Dec 11, 2018
@dkruchok
Copy link

dkruchok commented Jun 9, 2020

So maybe it's possible to control this with the library?
Something that can make it possible to prevent the request?
A simple example that doesn't work =)

            <input
                  matInput
                  placeholder="autocomplete"
                  formControlName="autocomplete"
                  (keyup)="onKey($event)"
                  ngx-google-places-autocomplete
                  #placesRef="ngx-places"
                  (onAddressChange)="handleAddressChange($event)"
                />
  onKey(event: Event) {
    if (this.form.controls.autocomplete.value.length < 4) {
      // stop API request
      event.stopImmediatePropagation();
      event.preventDefault();
      event.stopPropagation();
    }
  }

Would be great to have a method to stop request like this
@ViewChild('placesRef', { static: true }) placesRef: GooglePlaceDirective;

onKey(event: Event) {
    if (this.form.controls.autocomplete.value.length < 4) {
       this.placesRef.stop();
    }
}

@harleenarora
Copy link

any solution?

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

4 participants