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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -