Projekt

Obecné

Profil

Stáhnout (1.48 KB) Statistiky
| Větev: | Tag: | Revize:
1
/* 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
import { ObservationService } from './services/observation.service';
10
import { DataService } from './services/data.service';
11
import { AnalyticsService } from './services/analytics.service';
12

    
13
/**
14
 * Module that provides all services and configuration.
15
 */
16
@NgModule({
17
  imports: [],
18
  exports: [],
19
  declarations: [],
20
  providers: [
21
    LoginService,
22
    GroupService,
23
    ObservationService,
24
    DataService,
25
    AnalyticsService,
26
    ApiConfiguration
27
  ],
28
})
29
export class ApiModule {
30
  static forRoot(params: ApiConfigurationParams): ModuleWithProviders<ApiModule> {
31
    return {
32
      ngModule: ApiModule,
33
      providers: [
34
        {
35
          provide: ApiConfiguration,
36
          useValue: params
37
        }
38
      ]
39
    }
40
  }
41

    
42
  constructor( 
43
    @Optional() @SkipSelf() parentModule: ApiModule,
44
    @Optional() http: HttpClient
45
  ) {
46
    if (parentModule) {
47
      throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
48
    }
49
    if (!http) {
50
      throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
51
      'See also https://github.com/angular/angular/issues/20575');
52
    }
53
  }
54
}
(2-2/7)