I'm submitting a ... (check one with "x")
Current behavior:
nb-global-spinner doesnt hide
Expected behavior:
nb-global-spinner should disapear
Please explain what should trigger global-spinner display set to none
Hi @batousik, you can inject NbSpinnerService and call load method, to trigger all registered loaders (if any). This should hide the global spinner.
Hi guys,
I could solve this problem using the following code.
constructor(private spinner$: NbSpinnerService ) { }
ngOnInit() {
this.spinner$.load();
}
I also couldn't figure out why some routes would hide the spinner and others wouldn't so I went digging into the nebular code. For posterity, here's what I found:
NbLayoutComponent injects the NbSpinnerService and calls load() inside the the constructor.
NbLayoutComponent has nb-layout as a selector. So if you're not using nb-layout it won't get triggered, and therefore the spinner won't get cleared.
I found a solution
Inject private cdr: ChangeDetectorRef
constructor(
private cdr: ChangeDetectorRef
) {
run detect changes after changing the spinner
timer(2000).subscribe(() => {
this.isSpinLoading = false;
this.cdr.detectChanges();
});
Most helpful comment
I also couldn't figure out why some routes would hide the spinner and others wouldn't so I went digging into the nebular code. For posterity, here's what I found:
NbLayoutComponentinjects theNbSpinnerServiceand callsload()inside the the constructor.NbLayoutComponenthasnb-layoutas a selector. So if you're not usingnb-layoutit won't get triggered, and therefore the spinner won't get cleared.