在我的代碼之前,下面我想想着手離子3完成一個功能在進行下一個功能
this.driveTo();
前完成
this.storage.set ("location", JSON.stringify(lsd_info));
我相信我應該使用。那麼( )。我想知道的是在繼續之前有一個簡單的解決方案來完成一個事件。
getLoc() {
let a = this.data.lsd;
let b = this.data.sec;
let c = this.data.twp;
let d = this.data.rng;
let e = this.data.mrd;
this.http.get('https://www.reversegeocoder.com/api/v1/PrivateID/lsd/' + a + '-' + b + '-' + c + '-' + d + ' ' + e)
.map(res => res.json())
.subscribe (data => {
let lsd_info = {
latitude: data[0].response.lat,
longitude: data[0].response.lng,
};
let lsd_error = {error: data[0].response.err};
this.ErrorResponse = (JSON.stringify(data[0].response.err));
this.ErrorText = this.ErrorResponse.replace('[','').replace(']','');
this.storage.set ("location", JSON.stringify(lsd_info));
//finish storage.set before proceeding
this.driveTo();
},
err => {
console.log('error');
}
);
}
driveTo() {
this.navCtrl.push(Drive);
}
還是有兩個功能,其中在功能出發
即getLoc(),然後driveTo()
'this.storage.set do'是什麼? – echonax
@echonax它會根據平臺在設備或本地存儲的SQLite數據庫或瀏覽器中的鍵值對中設置鍵值對,應用程序使用'ionic-native','Storage'運行,插入。 – rmalviya
@echonax您可以查看離子存儲文檔[這裏](https://ionicframework.com/docs/storage/)。 – rmalviya