【发布时间】:2016-08-07 12:24:15
【问题描述】:
我将某些信息存储在 SqlStorage 中。当我尝试检索该信息时,我得到了一个承诺:
export class ProfileService {
this.storage = new Storage(sqlStorage);
get fname() {
this.storage.get('fname');
}
...
..
}
现在在显示用户个人资料时,我需要显示来自个人资料服务的信息:
@Page({
...
})
export class DisplayProfile {
fname: AbstractControl;
constructor(private _profile: ProfileService) {
// SEE HERE
this._profile.get('fname').then(value => {
this.fname.value = value;
});
this._profile.get('lname').then(value=>{
...
});
}
}
正如您在上面看到的,我正在解决页面构造器中的承诺。 我宁愿在页面加载之前解决这些承诺(就像 Angular1 状态更改中的解析块一样)。
有什么办法可以做到这一点吗?
【问题讨论】: