Angular TypeScript返回“&”:&引用;离子2应用程序中应为`
我在Angular 2/Ionic 2中的代码中遇到一个TypeScript错误:Angular TypeScript返回“&”:&引用;离子2应用程序中应为`,angular,typescript,ionic2,Angular,Typescript,Ionic2,我在Angular 2/Ionic 2中的代码中遇到一个TypeScript错误: constructor(){...} initializeApp() { this.platform.ready().then(() => { this.geolocation.getCurrentPosition().then((resp) => { // resp.coords.latitude
constructor(){...}
initializeApp() {
this.platform.ready().then(() => {
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
this.storageService.set("geolocation", {resp.coords.latitude, resp.coords.longitude} );
}).catch((error) => {
console.log('Error getting location', error);
});
});
}
错误:
Typescript Error
':' expected.
src/app/app.component.ts
// resp.coords.longitude
this.storageService.set("geolocation", {resp.coords.latitude, resp.coords.longitude} );
在“resp”之后的“.”上
我不熟悉TypeScript,我应该在这里声明什么吗?您应该将数据保存为数组或对象: 排列 反对
{latitude: resp.coords.latitude, longitude: resp.coords.longitude}
您应该将数据保存为数组或对象: 排列 反对
{latitude: resp.coords.latitude, longitude: resp.coords.longitude}
您的原始代码也不是有效的JS,因此您使用的是非常松散的解释器,或者结构在某些方面有所不同。您的原始代码也不是有效的JS,因此您使用的是非常松散的解释器,或者结构在某些方面有所不同。