2017-05-08 18 views
0

私はなぜこれらのエラーが発生しているのかわかりません。私が確認したところでは、構文が間違っているとか、何かがないとは思わない。私は間違っているかもしれません。私のコードを見てみてください:Typescript Error ';'予想される

Typescript Error 
';' expected. 

Typescript Error 
Declaration or statement expected. 

Typescript Error 
'try' expected. 

答えて

1

これを試してみてください:

import { Component } from '@angular/core'; 
import { NavController } from 'ionic-angular'; 
import { Geolocation } from '@ionic-native'; 

@Component({ 
    selector: 'page-home', 
    templateUrl: 'home.html' 
}) 
export class HomePage { 
coords:any; 
accuracy:any; 
error:any; 

    constructor(public navCtrl: NavController) { 

    } 

watch(){ 
    Geolocation.getCurrentPosition().then(resp) => { 
    this.coords= resp.coords.latitude+' '+resp.coords.longitude; 
    this.accuracy= resp.coords.accuracy+' '+'meters'; 
    }).catch((error)=>{ 
    this.error='Error getting location'+error; 
    }) 
} 

} 

これらは簡単でエラーログです//

watch(){ 
    Geolocation.getCurrentPosition().then((resp) => { 
    this.coords= resp.coords.latitude+' '+resp.coords.longitude; 
    this.accuracy= resp.coords.accuracy+' '+'meters'; 
    }).catch((error)=>{ 
    this.error='Error getting location'+error; 
    }); 
} 

を私はあなたが不足していると思います「。 "キャッチした後も、 "("、その後の後。

+1

感謝を持っているでしょう。私の悪い。 – camoflage

+0

あなたは」再歓迎:) –

+0

VSCodeなどの互換性のあるIDEを使用するので、手動でエラーを特定する必要はありません。 – unional

0
coords:any; 
accuracy:any; 
error:any; 

COORDSは

coords: number 

に変更することができ、その後、あなたはtypescriptです安全に

関連する問題