I have child component in my App Component
. To that child component i have attached one directive.
<app-complete autoCompletion #custom="autoCompletion" [autocompleteOptions]="autocompleteOptions" (optionSelected)="addChip($event)"></app-complete>
@Directive({
selector: '[autoCompletion]',
exportAs: 'autoCompletion'
})
export class AutoCompleteDirective {
@Input() autoCompletion;
}
If i want to access that directive in my App component
then i will do
app.component.ts
@ViewChild('custom') custom: ElementRef;
ngAfterViewInit() {
console.log('custom', this.custom);
}
but i can't find a way to do this directly in my child component.
I tried in app.complete.ts
file
@ViewChild('custom') custom: ElementRef;
ngAfterViewInit() {
console.log('custom', this.custom);
}
but i get printed undefined