common-ui/src/lib/loading/loading.module.ts
2023-05-29 23:21:35 +03:00

33 lines
1.4 KiB
TypeScript

import { ModuleWithProviders, NgModule, Optional } from '@angular/core';
import { FullPageLoadingIndicatorComponent } from './full-page-loading-indicator/full-page-loading-indicator.component';
import { ProgressLoadingComponent } from './progress-loading/progress-loading.component';
import { LoadingService } from './loading.service';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { CommonModule } from '@angular/common';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { ProgressBarComponent } from './progress-bar/progress-bar.component';
import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
const components = [FullPageLoadingIndicatorComponent, ProgressLoadingComponent, ProgressBarComponent];
@NgModule({
declarations: components,
exports: components,
imports: [MatProgressSpinnerModule, CommonModule, MatProgressBarModule, MatIconModule, TranslateModule],
})
export class IqserLoadingModule {
constructor(@Optional() loadingService: LoadingService) {
if (!loadingService) {
throw new Error('Call forRoot() in AppModule to use IqserLoadingModule');
}
}
static forRoot(): ModuleWithProviders<IqserLoadingModule> {
return {
ngModule: IqserLoadingModule,
providers: [LoadingService],
};
}
}