【发布时间】:2018-01-27 11:16:16
【问题描述】:
在模块中,我已经声明了指令,但 <div> 没有突出显示。
test.directive.ts
import { Directive, ElementRef, HostListener, Input } from "@angular/core";
@Directive({
selector: '[test]'
})
export class TestDirective {
@Input() highlightColor:string;
constructor(private el : ElementRef){
this.el.nativeElement.style.backgroundColor = this.highlightColor;
}
}
test.template.html
<div test highlightColor="red">directive testing</div>
【问题讨论】:
标签: angular angular2-directives