I've upgraded to Angular 8.2.3 and converted all my ViewChild calls to include the static parameter. Now I am having an issue accessing components if they are wrapped in an *ngIf.
Previously this worked and I was able to call the component's method:
html:
<div *ngIf="someBooleanResult">
...
<MyComponent #mycomponent1></MyComponent>
...
</div>
ts:
...
@ViewChild('mycomponent1') mycomponent1: MyComponent;
...
ngAfterViewInit () {
if(someBooleanResult) {
this.mycomponent1.someMethod();
}
}
Now, in Angular 8, mycomponent1 is always undefined with this @ViewChild call (I also tried static: true but that didn't work either):
@ViewChild('mycomponent1', { static: false}) mycomponent1: MyComponent;
What am I missing about the new ViewChild design?