-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.ts
43 lines (40 loc) · 1.31 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
43
import {NgModule, ModuleWithProviders, Provider} from "@angular/core";
import {Http, HttpModule} from "@angular/http";
import {CommonModule} from "@angular/common";
import {CountryPickerComponent} from "./src/country-picker.component";
import {CountryPickerService} from "./src/country-picker.service";
import {CountryPickerConfig, COUNTRY_PICKER_CONFIG, COUNTRY_PICKER_CONFIG_DEFAULT} from './src/country-picker.config'
export * from './src/country.interface';
export * from './src/country-picker.component';
export * from './src/country-picker.service';
export * from './src/country-picker.config';
export function countryPickerServiceFactory(config: CountryPickerConfig, http: Http) {
return new CountryPickerService(config, http);
}
@NgModule({
imports: [
CommonModule
],
declarations: [
CountryPickerComponent
],
exports: [
CountryPickerComponent
]
})
export class CountryPickerModule {
static forRoot(providedConfig: CountryPickerConfig = COUNTRY_PICKER_CONFIG_DEFAULT): ModuleWithProviders {
return {
ngModule: CountryPickerModule,
providers: [{
provide: COUNTRY_PICKER_CONFIG,
useValue: providedConfig
},
{
provide: CountryPickerService,
useFactory: countryPickerServiceFactory,
deps: [COUNTRY_PICKER_CONFIG, Http]
}]
};
}
}