You can use the "exportAs" property of the directive to then get the directive's instance from the decorated component.
For instance:
Create a dummy directive:
import { Directive } from '@angular/core'; @Directive({ standalone: true, selector: '[appDemoDirective]', exportAs: 'aDirective' // add here a name to get the instance later }) export class DemoDirective { aFunction(aParameter: string) { console.log(aParameter); } }
You can then get the directive instance using #variableName='aDirective'; i.e. a variable name = the export name you gave above
const template = ` <button appDemoDirective #directiveRef='aDirective' (click)="directiveRef.aFunction(message)">Click me</button> ` @Component({ selector: 'app-root', template: template }) export class AppComponent { public message = "Hello"; }
Clicking on button should call the directive's function and print "Hello" in this case