Is is possible to limit which component can have custom directive?
For example:
@Directive({
selector: '[myHighlight]',
host: "my-component" //!!!!!!!!!
})
export class HighlightDirective {
constructor(el: ElementRef) { //el is my-component - can not be nothing else !!!!
el.nativeElement.style.backgroundColor = 'yellow';
}
}
@Component({selector: "my-component"})...
Use case:
I would like to write directive for specific third-party component. I will use that third-party component properties, so directive on another component wouldn't make any sense and would throw errors.
That means that myHighlight
on div
would be ignored.