I have below code working before Angular 10 upgrade ie., Angular 8.
@viewChild in @injectable was working in Angular8 but not in Angular10 any reason ?
Code below is the sample (below is how my existing code looks):
@Injectable()
export abstract class DetailBaseComponent
extends BaseComponent {
/**
* Reference to the child modal component
*/
@ViewChild(ModalComponent)
modal: ModalComponent;
findDetail(){
console.log(this.modal); //undefined
this.modal.showModal = true;// error
}
But when i moved @viewChild from @Injectable to a component class then it was working fine. Is there any reason that we cannot use @viewChild except in component class then ??
Help Appreciated!