【发布时间】:2020-12-05 02:13:29
【问题描述】:
我在获取服务器响应时使用 ngx-loading 显示微调器。它运行良好:在请求发送时显示微调器,并在应用程序获得服务器响应时隐藏微调器。但是,如果我在显示微调器的区域时单击它,微调器不会隐藏,并且其他单击或按钮也无济于事。
LoadingModule 已正确导入
import { LoadingModule } from 'ngx-loading';
...
@NgModule({
imports: [
...
LoadingModule,
...
component.html:
<ngx-loading [show]="loading"></ngx-loading>
component.ts:
public loading = false;
...
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(300),
distinctUntilChanged(),
tap(term => this.loading = !!term.length),
switchMap(term => term.length > 0
? this.layersService.getLayerByID(term).pipe(
tap(data => this.searchFailed = false),
catchError((error) => {
this.searchFailed = true;
this.loading = false;
this.toastr.error(JSON.stringify(error.error), 'Server error',
{timeOut: 3000, positionClass: 'toast-bottom-right', tapToDismiss: false, closeButton: true});
return observableOf([]);
})
)
: []),
tap(() => this.loading = false));
【问题讨论】:
-
您能否尝试在堆栈闪电战中重现该问题?这也可能是一个错误......
标签: angular ngx-loading