import { Observable } from 'rxjs' ; import { NgModule , ModuleWithProviders } from '@angular/core' ; import { MyComponent } from './components/my-component' ; import { MyProvider } from './providers/my-provider' ; @ NgModule ( { declarations : [ MyComponent ] , exports : [ MyComponent ] } ) export class MyModule { static forRoot ( ) { return { ngModule : MyModule , providers : [ MyProvider ] } ; } }