Projekt

Obecné

Profil

Stáhnout (1.23 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

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

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