Attribute Directive
A directive that changes the look or behavior of an existing element.
What is Attribute Directive?
An attribute directive changes the look or behavior of an existing element. You write your own with @Directive and use it like an attribute.
@Directive({ selector: '[appHighlight]', host: { '(mouseenter)': 'on()', '(mouseleave)': 'off()' } })
export class Highlight {
private el = inject(ElementRef);
on() { this.el.nativeElement.style.background = 'yellow'; }
off() { this.el.nativeElement.style.background = ''; }
}
Level: Journeyman · More Angular terms at this level
Updated