【发布时间】:2019-03-05 13:54:53
【问题描述】:
我使用“离子加载控制器”来显示一个微调器,直到检索到数据然后它调用“dismiss()”来解除它。 它工作正常,但有时当应用程序已经拥有数据时,会在“create()”和“present()”完成之前调用“dismiss()”,这将使微调器不会被解雇......
我尝试调用“loadingController.present().then()”里面的数据,但是导致数据变慢了……
这是一个错误吗? 如何解决这个问题?
我的代码示例:
customer: any;
constructor(public loadingController: LoadingController, private customerService: CustomerService)
ngOnInit() {
this.presentLoading().then(a => consloe.log('presented'));
this.customerService.getCustomer('1')
.subscribe(customer => {
this.customer = customer;
this.loadingController.dismiss().then(a => console.log('dismissed'));
}
}
async presentLoading() {
const loading = await this.loadingController.create({
message: 'wait. . .',
duration: 5000
});
return await loading.present();
}
【问题讨论】:
-
您解决了吗?我也有同样的问题
-
我会写下我的解决方法作为答案,但我不是 100% 肯定是最好的方法
标签: angular ionic-framework angular6 loading ionic4