@angular-magic/ngx-gp-autocomplete
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

ngx-gp-autocomplete

Ngx-Markdown Logo

Demo: https://ngx-gp-autocomplete.angularmagic.com

This module is a wrapper for Google Places Autocomplete js library. Initial code base was copied from this project ngx-google-places-autocomplete, this module applies some fixes and improvements. Like @types/google.maps and @googlemaps/js-api-loader

NPM

Installation

npm

npm install @angular-magic/ngx-gp-autocomplete
npm install @googlemaps/js-api-loader
npm install --save @types/google.maps

Integration

  • Import NgxGpAutocompleteModule into your application module
import { NgxGpAutocompleteModule } from "@angular-magic/ngx-gp-autocomplete";

@NgModule({
  imports: [
    NgxGpAutocompleteModule,
    BrowserModule,
    FormsModule,
    //...
  ],
  providers: [
    {
      provide: Loader,
      useValue: new Loader({
        apiKey: 'YOUR_API_KEY',
        libraries: ['places']
      })
    },
    //...
  ],
  //...
})
<input #placesRef="ngx-places" ngx-gp-autocomplete [options]='options' (onAddressChange)="handleAddressChange($event)"/>
  • Additionally you can reference directive in your component
export class Component {
  @ViewChild('ngxPlaces') placesRef: NgxGpAutocompleteDirective;

  public handleAddressChange(place: google.maps.places.PlaceResult) {
    // Do some stuff
  }
}

GitHub

Please feel free to declare issues or contribute: https://github.com/angular-magic/ngx-gp-autocomplete

Package Sidebar

Install

npm i @angular-magic/ngx-gp-autocomplete

Weekly Downloads

5,947

Version

2.0.2

License

MIT

Unpacked Size

44.4 kB

Total Files

16

Last publish

Collaborators

  • dancornilov