Last active
July 22, 2018 21:19
-
-
Save mav-erick/f3b8a3c130d73ca64252b1468370dc3a to your computer and use it in GitHub Desktop.
Google places autocomplete app.component.ts v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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