Is it possible to access the selector name inside a Directive? I have multiple components using the same directive and need to identify the current component's selector. Here is an example:
<my-component1 *myDir="Var"></my-component1>
<my-component2 *myDir="Var"></my-component2>
<my-component3 *myDir="Var"></my-component3>
I want to get the current component selector name inside the Directive as shown below. Can anyone guide me on how to achieve this?
@Directive({
selector: '[myDir]'
})
export class MyDirDirective {
constructor() {
this.currentSelector = getCurrentComponentSelector();
}
}
@Input() set myDir(value:any){
if(this.currentSelector === 'my-component1'){
// Perform specific action based on the selector
}
}