@elemental/common / Class

LmnTemplateOutletDirective

Decorators:@Directive
Generic types:C
Selectors:[lmnTemplateOutlet]
Implements:OnChanges

An equivalent of ngTemplateOutlet directive but with the ability to provide the current Directive injector to the template. This is useful when you need to create the template that need to has access to the parent injector depending on the current concrete position into the dom.

Properties

NameTypeDescription
context
r
InputSignal<C | null>

A context object to attach to the {@link EmbeddedViewRef}. This should be an object, the object's keys will be available for binding by the local template let declarations. Using the key $implicit in the context object will set its value as default.

injectorFn
r
InputSignal<LmnCustomInjectorFn | null>

A function that receive as input the injector of current directive and must be return the Injector to use for the template.

templateRef
r
InputSignal<TemplateRef<C> | null>

A string defining the template reference and optionally the context object for the template.

Example usage

If you have a component that receive a template that represent an input radio, that request to access to the LMN_RADIO_GROUP token, with the Angular directive the parent injector of the template is inherit from the component that declare the template and break the component. With this directive instead the template receive as injector the current directive injector that is instantiated internally of input-radio-group component.