angular/aio/content/examples/ngmodule-faq/src/app/highlight.directive.1.ts

16 lines
423 B
TypeScript

// #docplaster
// #docregion
import { Directive, ElementRef } from '@angular/core';
// Highlight the host element in gold
@Directive({ selector: '[highlight]' })
export class HighlightDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'gold';
// #enddocregion
console.log(`* AppRoot highlight called for ${el.nativeElement.tagName}`);
// #docregion
}
}
// #enddocregion