Projekt

Obecné

Profil

Stáhnout (1.3 KB) Statistiky
| Větev: | Tag: | Revize:
1 f8b9a3a2 hlavja
/* tslint:disable */
2
/* eslint-disable */
3
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
4
import { HttpClient } from '@angular/common/http';
5
import { ApiConfiguration, ApiConfigurationParams } from './api-configuration';
6
7
import { LoginService } from './services/login.service';
8
import { GroupService } from './services/group.service';
9 1d6ec56f hlavja
import { DataService } from './services/data.service';
10 f8b9a3a2 hlavja
11
/**
12
 * Module that provides all services and configuration.
13
 */
14
@NgModule({
15
  imports: [],
16
  exports: [],
17
  declarations: [],
18
  providers: [
19
    LoginService,
20
    GroupService,
21 1d6ec56f hlavja
    DataService,
22 f8b9a3a2 hlavja
    ApiConfiguration
23
  ],
24
})
25
export class ApiModule {
26
  static forRoot(params: ApiConfigurationParams): ModuleWithProviders<ApiModule> {
27
    return {
28
      ngModule: ApiModule,
29
      providers: [
30
        {
31
          provide: ApiConfiguration,
32
          useValue: params
33
        }
34
      ]
35
    }
36
  }
37
38
  constructor( 
39
    @Optional() @SkipSelf() parentModule: ApiModule,
40
    @Optional() http: HttpClient
41
  ) {
42
    if (parentModule) {
43
      throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
44
    }
45
    if (!http) {
46
      throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
47
      'See also https://github.com/angular/angular/issues/20575');
48
    }
49
  }
50
}