-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.module.ts
More file actions
35 lines (32 loc) · 1.35 KB
/
api.module.ts
File metadata and controls
35 lines (32 loc) · 1.35 KB
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
32
33
34
35
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';
import { BusinessManagementService } from './whatsapi/businessManagement.service';
import { GroupManagementService } from './whatsapi/groupManagement.service';
import { InstanceService } from './whatsapi/instance.service';
import { MessageSendingService } from './whatsapi/messageSending.service';
import { MiscellaneousService } from './whatsapi/miscellaneous.service';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: []
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
return {
ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
};
}
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
@Optional() http: HttpClient) {
if (parentModule) {
throw new Error('ApiModule 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');
}
}
}