Skip to content

Instantly share code, notes, and snippets.

@mav-erick
Last active July 22, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mav-erick/f3b8a3c130d73ca64252b1468370dc3a to your computer and use it in GitHub Desktop.
Save mav-erick/f3b8a3c130d73ca64252b1468370dc3a to your computer and use it in GitHub Desktop.
Google places autocomplete app.component.ts v2
import { Component, NgZone } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public title = 'Places';
public addrKeys: string[];
public addr: object;
//Method to be invoked everytime we receive a new instance
//of the address object from the onSelect event emitter.
setAddress(addrObj) {
//We are wrapping this in a NgZone to reflect the changes
//to the object in the DOM.
this.zone.run(() => {
this.addr = addrObj;
this.addrKeys = Object.keys(addrObj);
});
}
constructor(private zone: NgZone) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment