I set element reference to my input,
export class MyComponent implements OnInit{
@ViewChild("mySearchElement") // <input #mySearchElement
public searchElementRef: ElementRef;
...and bind it with google maps autosearch, which works fine.
new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, ...
What I try to do is, I want to render whole template after ajax call is completed. So I added a property to my component,
public isDataLoaded = false
and I set this true only after ajax work is completed.
<div *ngIf="isDataLoaded">
....my search element is within this wrapper.
...but when I do this, autocomplete cannot find searchElementRef, which is understandable.
How can I set viewchild after my ajax call is completed? This doesn't work:
function ajaxCallCompleted() { // Callback once ajax is completed.
this.isDataLoaded = true
@ViewChild("mySearchElement") this.searchElementRef: ElementRef;
new google.maps.places.Autocomplete(this.searchElementRef.nativeElement ....
}