OpenSlides/client/src/app/core/core.module.ts
Sean Engelhardt 76ce18cfd8 Add modules and lazy loading
- core modules contains core services
- shared module contains "dumb" components (directives, models)
  - used by nearly all modules
- site, it's children and projector are now feature modules
  - full lazy loading with independent routing
  - routing for children (extremely helpful for plugins (later))
2018-08-15 10:19:46 +02:00

47 lines
1.4 KiB
TypeScript

import { NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Title } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
// Core Services, Directives
import { AuthGuard } from './services/auth-guard.service';
import { AuthService } from './services/auth.service';
import { AutoupdateService } from './services/autoupdate.service';
import { DataStoreService } from './services/dataStore.service';
import { OperatorService } from './services/operator.service';
import { WebsocketService } from './services/websocket.service';
import { AddHeaderInterceptor } from './http-interceptor';
/** Global Core Module. Contains all global (singleton) services
*
*/
@NgModule({
imports: [CommonModule],
providers: [
Title,
AuthGuard,
AuthService,
AutoupdateService,
DataStoreService,
OperatorService,
WebsocketService,
{
provide: HTTP_INTERCEPTORS,
useClass: AddHeaderInterceptor,
multi: true
}
]
})
export class CoreModule {
/** make sure CoreModule is imported only by one NgModule, the AppModule */
constructor(
@Optional()
@SkipSelf()
parentModule: CoreModule
) {
if (parentModule) {
throw new Error('CoreModule is already loaded. Import only in AppModule');
}
}
}