import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule, APP_INITIALIZER } from '@angular/core'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { MatGridListModule } from '@angular/material/grid-list'; import { SharedModule } from './shared/shared.module'; import { AppComponent } from './app.component'; import { AuthHeaderInterceptor } from './interceptors/header.interceptor'; import { CatchErrorInterceptor } from './interceptors/http-error.interceptor'; import { AppRoutingModule } from './app-routing.module'; import { HeaderComponent } from './header/header.component'; import { HomeComponent } from './home/home.component'; import { AuthService } from './shared/services'; import { HeroComponent } from './hero/hero.component'; import { CreateComponent } from './create/create.component'; import { ViewdataComponent } from './viewdata/viewdata.component'; import { EditComponent } from './edit/edit.component'; import { MatTableModule } from '@angular/material/table'; export function appInitializerFactory(authService: AuthService) { return () => authService.checkTheUserOnTheFirstLoad(); } @NgModule({ imports: [BrowserAnimationsModule, HttpClientModule, SharedModule, AppRoutingModule, MatGridListModule, MatTableModule], declarations: [AppComponent, HeaderComponent, HomeComponent, HeroComponent, CreateComponent, ViewdataComponent, EditComponent], providers: [ { provide: HTTP_INTERCEPTORS, useClass: AuthHeaderInterceptor, multi: true, }, { provide: HTTP_INTERCEPTORS, useClass: CatchErrorInterceptor, multi: true, }, { provide: APP_INITIALIZER, useFactory: appInitializerFactory, multi: true, deps: [AuthService], }, ], bootstrap: [AppComponent], }) export class AppModule { }