1
在该模块中,我已经宣布了指令,但<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>