projects/maplander/core/src/lib/meta/meta.module.ts
Static forRoot |
forRoot()
|
Returns :
ModuleWithProviders
|
import {APP_INITIALIZER, ModuleWithProviders, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {MetaService} from './meta.service';
@NgModule({
imports: [
CommonModule,
]
})
export class MetaModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: MetaModule,
providers: [
MetaService,
{
provide: APP_INITIALIZER,
useFactory: init,
multi: true,
deps: [MetaService]
}
]
};
}
}
export function init(service: MetaService) {
const f = () => service.init();
return f;
}