I need to add a attribute to the content via this directive.
@Directive({
selector: '[myStructuralDirective]'
})
export class MyStructuralDirectiveDirective {
@Input()
set myStructuralDirective(key: string) {
key ? (this.viewContainerRef.createEmbeddedView(this.templateRef), this.renderer.setAttribute(...) ): this.viewContainerRef.clear();
}
constructor(
private readonly renderer: Renderer2,
private readonly templateRef: TemplateRef<any>,
private readonly viewContainerRef: ViewContainerRef
) {}
}
usage:
<custom-element-1 *myStructuralDirective="classProperty">Test custom element 1</custom-element-1>
I don't find any method exposed via templateRef
to do so.