angular-cn/public/docs/_examples/attribute-directives/ts/src/app/highlight.directive.1.ts

14 lines
368 B
TypeScript
Raw Normal View History

// #docregion
import {Directive, ElementRef, Renderer, Input} from 'angular2/angular2';
@Directive({
selector: '[my-highlight]'
})
export class Highlight {
constructor(el: ElementRef, renderer: Renderer) {
//el.nativeElement.style.backgroundColor = 'yellow';
renderer.setElementStyle(el, 'background-color', 'yellow');
}
}
// #enddocregion