这是正常的这样或什么是最好的使用情况,以通话,因为没有别的工作如何使用离子储存得到?
this.storage.get('email').then((email) => {
this.storage.get('token').then((token) => {
this.http.get('https://app.dev/clients.json?login='+email+'&client_token='+token)
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.data = data;
resolve(this.data);
});
});
});
});
我试图
data: any;
token: string;
phone:string;
constructor(private http: Http, public storage: Storage) {}
load() {
this.storage.get('token').then((token) => {
this.token = token;
});
this.storage.get('phone').then((phone) => {
this.phone = phone;
});
this.http.get('https://app.dev/clients.json?login='+this.phone+'&client_token='+this.token)
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.data = data;
resolve(this.data);
});
});
但this.phone =电话;未分配
我希望我可以叫this.storage.get(“手机”),并没有承诺。
只能做'this.phone = this.storage.get('phone');'? – Huiting
没有它的承诺。 – flakerimi
你正在使用什么类型的存储? – Huiting