0

i am using google auto complete in my IOS Ionic 2 app. When i start typing an address in a field the matching addresses appear ok in a drop down list but if I select one, the ion-input field is not populated. Could anyone help me how to fix this?

This is my template:

<ion-item>
<ion-input id="journey_from" name="journey_from" type="text" placeholder="" [(ngModel)] = "location"></ion-input>
</ion-item>

This is my component:

  ngAfterViewInit(){
    let options = {
      componentRestrictions:{
        country: 'IN'
      },
      types: ['(regions)']
    }
    let input = document.getElementById('autocomplete').getElementsByTagName('input')[0];
    let autoComplete = new google.maps.places.Autocomplete(this.autocomplete.nativeElement,options );
    google.maps.event.addListener(autoComplete,'place_changed', () => {
     this.placeSelect = autoComplete.getPlace();
 this.location= this.placeSelect.formatted_address;

     this.changeDetect.detectChanges();   });
ARD
  • 145
  • 2
  • 15
  • where is location set in the code? by _ion-item is not populated_ you mean the ion-input? – Suraj Rao Mar 18 '17 at 08:51
  • Yeah sorry. ion-input – ARD Mar 18 '17 at 08:56
  • @Dheena please take a look at [this SO post](http://stackoverflow.com/questions/38174997/angular-2-ionic-2-detect-if-an-object-was-modified/38180523#38180523) – sebaferreras Mar 18 '17 at 09:12
  • @sebaferreras My issue was, Address was not populating on ion-input, when i select the address from google autocomplete. – ARD Mar 19 '17 at 02:44

1 Answers1

1

UPDATE

You probably use the CDVUIWebViewEngine. Try to update to WKWebView to resolve your problem ;) You can find here how to upgrade your web view engine. If you use angularhttp, you'll need to use ionic-native@http instead for iOS (best way to resolve cors issues with angular-http and WKWebView). Good luck guys :D

Sokatoha
  • 66
  • 4