angular-cn/public/docs/_examples/ngmodule/ts/app/highlight.directive.ts

13 lines
367 B
TypeScript
Raw Normal View History

2016-07-12 18:14:13 -07:00
// #docregion
import { Directive, ElementRef } from '@angular/core';
2016-07-12 18:14:13 -07:00
@Directive({ selector: '[highlight]' })
/** Highlight the attached element in gold */
export class HighlightDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'gold';
2016-07-12 18:14:13 -07:00
console.log(
`* AppRoot highlight called for ${el.nativeElement.tagName}`);
}
}