import { Directive, effect, ElementRef, inject, input, Renderer2 } from '@angular/core'; @Directive({ selector: '[kcAttributes]' }) export class AttributesDirective { kcAttributes = input>(); readonly #el = inject>(ElementRef); readonly #renderer = inject(Renderer2); constructor() { effect(() => { const attributes = this.kcAttributes(); if (attributes) { Object.entries(attributes).forEach(([key, value]) => { this.#renderer.setAttribute( this.#el.nativeElement, `data-${key}`, value ); }); } }); } }