@NgModule() class instantiate
artaommahe opened this issue · comments
There is some use-cases where some services don't have public methods and never used/injected by other components/services. This services inject other services and works with them on some events/etc. At ng1 we can use module.run()
function to initialize this services, inject them at this function.
As i see at ng2 we can do this
@Injectable()
class SmthService {
constructor() { console.log('SmthService'); }
}
@NgModule({
providers: [ SmthService ],
})
export class AppModule {
constructor(_smth: SmthService) {}
}
and this works as expected.
But looks like ng-metadata does not create module class instance and constructor is never called.
It would be useful to have modules classes instantiated.
just curious, can you provide some official docs or article where are they using NgModule class constructor for this kind of instantiation ? thx
implementation Notes:
- when
bundle
is called it should register ng1.run
hook with properly annotated injectables
dont think it is getting called ..