-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.module.ts
31 lines (28 loc) · 1.1 KB
/
api.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { letheanSDPConfiguration } from './configuration';
import { HttpClient } from '@angular/common/http';
import { VpnService } from './api/vpn.service';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: []
})
export class letheanSDPApiModule {
public static forRoot(configurationFactory: () => letheanSDPConfiguration): ModuleWithProviders {
return {
ngModule: letheanSDPApiModule,
providers: [ { provide: letheanSDPConfiguration, useFactory: configurationFactory } ]
};
}
constructor( @Optional() @SkipSelf() parentModule: letheanSDPApiModule,
@Optional() http: HttpClient) {
if (parentModule) {
throw new Error('letheanSDPApiModule is already loaded. Import in your base AppModule only.');
}
if (!http) {
throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
'See also https://github.com/angular/angular/issues/20575');
}
}
}