Call value latitude and longitude geolocation to view html

#1

hello myfriend, i have a problem, how to call value long and lat to view html. this value can appear on console.log.


i want to call value to form html.
this form home.html

      <form (ngSubmit)="saveUser()">
            <ion-item>
              <ion-label color="primary" floating>name</ion-label>
              <ion-input [(ngModel)]="user.namaTempat" name="namaTempat"></ion-input>
            </ion-item>
            <ion-item>
                <ion-label color="primary" floating>latitude</ion-label>
                <ion-input [(ngModel)]="user.latitude" name="latitude"></ion-input>
              </ion-item>
              <ion-item>
                  <ion-label color="primary" floating> longlitude</ion-label>
                  <ion-input [(ngModel)]="user.longitude" name="longitude"></ion-input>
                </ion-item>
                <button ion-button full type="submit">Save</button>
              </form>

and below this this home.ts
import { Component,ViewChild, ElementRef } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { NextPage } from ‘…/next/next’;
import { Geolocation } from ‘@ionic-native/geolocation’;
import { RestProvider } from ‘…/…/providers/rest/rest’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

latitude: number;
longitude: number;
users: any;
data:any;
user = {namaTempat : ‘’};

constructor(public navCtrl: NavController, public geolocation: Geolocation, public restProvider: RestProvider) {

      this.getUsers();
      this.geolocation.getCurrentPosition().then((resp) => {
        let userLocations = {
          latitude: resp.coords.latitude,
          longitude : resp.coords.longitude
        }
      console.log("Locations acquired");
      console.log(userLocations);
      this.latitude = resp.coords.latitude
      this.longitude = resp.coords.longitude
      }).catch((error) => {
        console.log('Error getting location', error);
      });

    }
      getUsers(){
        this.restProvider.getUsers()
          .then(data => {
          this.users = data;
          console.log(this.users);
      });
}