@Directive({
selector: '[myHighlight]'
})
export class HighlightDirective {
static test: number = 5;
constructor(private el: ElementRef) { }
highlight(color: string) {
this.el.nativeElement.style.backgroundColor = color;
}
}
In relation to the provided code snippet, I am curious about the scenario where there is no myHighlight
attribute present to trigger Angular to instantiate an object of the HighlightDirective
class. In such a case, my assumption is that the HighlightDirective
class itself (without instantiation) will be created. Is my understanding correct? If so, what would be the method to access the class?