@
@
@atmk2021-01-26 13:40:30
Angular
@atmk, 2021-01-26 13:40:30

How to implement ViewChild in Angular?

Child component of EditPanelComponent. I'm trying to access it via ViewChild.
The object is not defined . I've read a lot. Tried different options.
It turns out that ViewChild cannot be used at all...???
If anyone knows, tell me how???

@ViewChild(EditPanelComponent)
private editPanelComponent: EditPanelComponent;

ngAfterViewInit() {
console.log(this.editPanelComponent); // undefined DOESN'T WORK
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2021-01-26
@Xuxicheta

What's in the markup? Everything is fine with ViewChild,
https://stackblitz.com/edit/angular-ivy-2hljgw?dev...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question