如何在angular 4中显示无http服务调用的微调器
在我的angular应用程序中,我想在不进行http调用的情况下返回obervable或订阅或承诺。 当这个函数返回它们中的任何一个时,我需要显示一个微调器。我尝试了下面的方法,但没有成功。 我无法在这个.busy1中看到微调器,但我可以在这个.busy中看到微调器。 可以将this.component.processFunc()和this.processData()合并为一个承诺。 但是执行应该是 步骤1:this.component.processFunc() 步骤2:this.processData()文件 文件如何在angular 4中显示无http服务调用的微调器,angular,promise,spinner,Angular,Promise,Spinner,在我的angular应用程序中,我想在不进行http调用的情况下返回obervable或订阅或承诺。 当这个函数返回它们中的任何一个时,我需要显示一个微调器。我尝试了下面的方法,但没有成功。 我无法在这个.busy1中看到微调器,但我可以在这个.busy中看到微调器。 可以将this.component.processFunc()和this.processData()合并为一个承诺。 但是执行应该是 步骤1:this.component.processFunc() 步骤2:this.proces
busy: Promise<any>;
busy1: Promise<any>;
@ViewChild('component') ComponentView;
this.busy1 = this.asyncPromiseViewtest().then(data => {
//do some stuff
});
asyncPromiseViewtest() {
return new Promise((resolve, reject) => {
resolve(this.component.processFunc());
});
}
this.busy = this.asyncPromise().then(data => { //do some stuff });
asyncPromise() { return new Promise((resolve, reject) => {
resolve(this.processData());
});
processData() {
//no promise return //do some logic }
HTML:
<div [ngBusy]="{busy: [busy, busy1], backdrop: true, delay: 200, minDuration: 600}">
忙:承诺;
忙碌1:承诺;
@ViewChild(“组件”)组件视图;
this.busy1=this.asyncPromiseViewtest()。然后(数据=>{
//做点什么
});
asyncPromiseViewtest(){
返回新承诺((解决、拒绝)=>{
解析(this.component.processFunc());
});
}
this.busy=this.asyncPromise().then(data=>{//do some stuff});
asyncPromise(){返回新承诺((解析,拒绝)=>{
解析(this.processData());
});
processData(){
//无承诺返回//执行一些逻辑}
HTML:
我推断this.component.processFunc()
和this.processData()
是同步的但很长的进程,您希望在进程进行时显示微调器。对吗?@Roamer,它们是同步的,一个必须等待另一个。我需要显示微调器