Created
December 11, 2018 00:01
-
-
Save LayZeeDK/e4dd2fb1331bb01a01c9d75ad2413b79 to your computer and use it in GitHub Desktop.
The forRoot pattern for singleton services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ModuleWithProviders, NgModule } from '@angular/core'; | |
import { MyComponent } from './my.component'; | |
import { PreSixSingletonService } from './pre-six-singleton.service'; | |
@NgModule({ | |
declarations: [ | |
MyComponent, | |
], | |
}) | |
export class PreSixModule { | |
static forRoot(): ModuleWithProviders { | |
return { | |
ngModule: PreSixmodule, | |
providers: [ | |
PreSixSingletonService, | |
], | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment