Reputation: 1144
In Angular 1 all Services and Directives had to be added to the Angular Application before the Bootstrap Phase. Angular 2 has a new concept of injection and has introduced hierarchical Injectors. Do hierarchical Injectors enable you to add Services and Components in Angular2 after the Bootstrap Phase.
Upvotes: 1
Views: 380
Reputation: 657338
No, you need to add providers statically and therefore they need to be known and registered at bootstrap time.
The hierarchy of injectors is determined by the components and directives hierarchy and providers are configured in static component and directives metadata. There is nothing you can modify at runtime.
You can create an independent injector hierarchy or a sub-hierarchy of a component/directive injector unrelated to components where you can configure providers at runtime.
If you instantiate or create components dynamically at runtime you can somehow work around and define providers at runtime for this component and descendants (as far as they don't have providers for the same key already)
like demonstrated in
Upvotes: 1