Last active
September 8, 2022 01:38
-
-
Save fireflysemantics/2fe61964fb53ae173d9dcd7f5937ee76 to your computer and use it in GitHub Desktop.
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 { GreetingService } from './greeting.service'; | |
import { GreetingServiceConfig } from './greeting-service.config'; | |
import { GREETING_SERVICE_CONFIG_INJECTION_TOKEN } from './greeting-service.token'; | |
@NgModule({ | |
providers: [GreetingService], | |
}) | |
export class GreetingServiceModule { | |
constructor(greetingService: GreetingService) { | |
greetingService.initialize(); | |
} | |
static config( | |
config?: Partial<GreetingServiceConfig> | |
): ModuleWithProviders<GreetingServiceModule> { | |
return { | |
ngModule: GreetingServiceModule, | |
providers: [ | |
{ | |
provide: GREETING_SERVICE_CONFIG_INJECTION_TOKEN, | |
useValue: Object.assign(new GreetingServiceConfig(), config), | |
}, | |
], | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment