import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { SwitchComponent } from './switch.component'; import { SWITCH_OPTIONS } from './switch.token'; import { SwitchModuleConfig } from './switch.config'; @NgModule({ declarations: [SwitchComponent], imports: [CommonModule, FormsModule], exports: [FormsModule, SwitchComponent] }) export class SwitchModule { static forRoot(config?: SwitchModuleConfig | null | undefined): ModuleWithProviders { return { ngModule: SwitchModule, providers: [{ provide: SWITCH_OPTIONS, useValue: config || {} }] }; } }