Help Im new :(

hi, im new here, i was follow tutorials, but i have 2 problems,

i dont have error message on terminal about this. (the next message show in Firefox , chrome and ie)

1: Runtime Error
Error in ./HomePage class HomePage - caused by: Cannot read property ‘getCurrentPosition’ of undefined

Code:

/ import { Component } from ‘@angular/core’;
/ import { Geolocation } from ‘@ionic-native/geolocation’;
/ import { NavController } from ‘ionic-angular’;

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

/ export class HomePage {

/ geolocation: Geolocation;
/ coords : any;
/ accuracy: any;
/ error: any;

/ constructor(public navCtrl: NavController) {}
/ watch() {

 / this.geolocation.getCurrentPosition().then((resp)=>{
  /  this.coords = resp.coords.latitude + ' ' + resp.coords.longitude;
   / this.accuracy.coords.accuracy + 'meters'; 
    /    }).catch((error) =>{ 
     /      this.error='Error al obtener la ubicacion.';

/ })

/ }
/ }

  1. dont show nothing, i cant see anything un my explorer, why?
    if i remove tag, and then works…

code:
/
/
/ <button ion-button (click)=“watch()”>Obtener mi posicion
/

Position: {{ coords }}


/

Accuracity: {{ accuracity }}


/ <p *ngIf=“error”> {{ error }}
/
/

— help, please, i want to keep going Through the tutorials :frowning:

Welcome, please format your code correctly when you post it so people can read it.

The problem it seems, as the error states, is that geolocation is undefined, you need to inject it in your constructor like you do the NavController.

The problem I see is that geolocation is not declared as any variable within the class, you have to pass it to the constructor. You should read the documentation so that you avoid headaches.

Geolocation Documentation