Class Overview
class NgComponentOutlet implements OnChanges, OnDestroy {
constructor
(_viewContainerRef: ViewContainerRef)
ngComponentOutlet
: Type<any>
ngComponentOutletInjector
: Injector
ngComponentOutletContent
: any[][]
ngComponentOutletNgModuleFactory
: NgModuleFactory<any>
ngOnChanges
(changes: SimpleChanges)
ngOnDestroy
()
}
Selectors
[ngComponentOutlet]
Class Description
Instantiates a single Component
type and inserts its Host View into current View.
NgComponentOutlet
provides a declarative approach for dynamic component creation.
NgComponentOutlet
requires a component type, if a falsy value is set the view will clear and
any existing component will get destroyed.
Fine tune control
You can control the component creation process by using the following optional attributes:
ngComponentOutletInjector
: Optional customInjector
that will be used as parent for the Component. Defaults to the injector of the current view container.ngComponentOutletProviders
: Optional injectable objects (Provider
) that are visible to the component.ngComponentOutletContent
: Optional list of projectable nodes to insert into the content section of the component, if exists.ngComponentOutletNgModuleFactory
: Optional module factory to allow dynamically loading other module, then load a component from that module.
Syntax
Simple
Customized injector/content
Customized ngModuleFactory
Example
A more complete example with additional options:
A more complete example with ngModuleFactory:
Class Details
exported from common/index, defined in common/src/directives/ng_component_outlet.ts