ngx-spinner
first paste below script to your package.json:
"scripts": {
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
}
}
ngx-spinner
and check again
hi guys, any idea why spinner is not being hide on finalize?
a.component.ts
ngAfterViewInit() {
this.subscriptions.add(
this.organizationsService.organizations$
.pipe(
tap(() => {
this.spinnerService.showLoader();
}),
finalize(() => {
this.spinnerService.hideLoader();
}),
takeUntil(this.destroySubject))
.subscribe(response => {
this.cachedFacts = this.cachedFacts.concat(response);
if (!this.searchService.search.value.length) {
this.dataSource.data = this.cachedFacts as IOrganizations[];
this.dataSource.sort = this.sort;
} else {
this.dataSource.data = response as IOrganizations[];
this.cachedFacts = [];
}
this.filterSelectObj.filter((o) => {
o.options = this.getFilterObject(this.dataSource.data, o.columnProp);
});
}, (error) => {
this.errorService.handleError(error);
})
);
}
spinner.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { NgxSpinnerService } from 'ngx-spinner';
@Injectable()
export class SpinnerService {
constructor(private spinnerService: NgxSpinnerService) { }
public showLoaderSubject = new BehaviorSubject<boolean>(false);
showLoader() {
// this.showLoaderSubject.next(true);
this.spinnerService.show();
}
hideLoader() {
// this.showLoaderSubject.next(false);
this.spinnerService.hide();
}
}
spinner.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SpinnerComponent } from './spinner.component';
import { NgxSpinnerModule, NgxSpinnerService } from 'ngx-spinner';
import { SpinnerService } from '@shared/services/spinner.service';
@NgModule({
imports: [
CommonModule,
NgxSpinnerModule
],
declarations: [SpinnerComponent],
exports: [SpinnerComponent],
providers: [SpinnerService, NgxSpinnerService]
})
export class SpinnerModule { }