Show data in ionic template -
so want show result of geopositioning in template view.i error "cannot read property coords of undefined" below codes
getgeolocationposition() {          this.geolocation.getcurrentposition().then((resp) => {                     var lati = resp.coords.latitude;          var longi = resp.coords.longitude;          // let pos = {          //   lat: resp.coords.latitude,          //   lng: resp.coords.longitude,                      // };          console.log(lati, longi);        }).catch((error) =>{          console.log('error getting location' + json.stringify(error) );        });          }  <ion-card>      <ion-card-header>what's current location?</ion-card-header>      <ion-card-content>        <button ion-button round (click)="getgeolocationposition()">get location</button>        <ion-input readonly="true" placeholder="latitude">{{resp.coords.latitude}}</ion-input>        <ion-input readonly="true" placeholder="longitude"></ion-input>      </ion-card-content>    </ion-card>  
give class property called georesult , set resp object async ionic native call.
this.georesult = resp:
in html, interpolate using georesult
{{ georesult.coords.latitude }}
Comments
Post a Comment