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

15 lines
512 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
// Same directive name and selector as
// HighlightDirective in parent AppRootModule
// It selects for both input boxes and 'highlight' attr
// and it highlights in beige instead of yellow
@Directive({ selector: '[highlight]' })
export class HighlightDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'beige';
2016-07-12 18:14:13 -07:00
console.log(`* Hero highlight called for ${el.nativeElement.tagName}`);
}
}