I was using ViewChild as follows:
@ViewChild("InternalMedia") localStream;
@ViewChild("emoji") mEmoji;
Which was working fine till angular-7.x
as soon as I upgraded it to angular-8.x it started giving following error
.../call_emoji/component.ts(41,4): error TS2554: Expected 2 arguments, but got 1.
I checked https://angular.io/api/core/ViewChild and when I change it to
@ViewChild("InternalMedia",{static:false}) remoteStream;
It works. I'm not getting what static does and what should be it's value to work as previous?
After migration to Angular 8 you should declare manually if it's static or not
If you have further questions ask them or for more details please read this issue https://github.com/angular/angular-cli/issues/14553 or take a look at offical documentation https://angular.io/guide/static-query-migration
According to the Angular documentation static checks
Effectively this determines when the query is run to retrieve the element. If set to false the query will be run after any change detections. If set to true it will be run immediately.
For more information and why this option is included please see this Github issue.
The behavior you are probably looking for is to set
static
to false. This will result in the old behavior. However if your component's view is not dynamic (for example you do not use *ngIf) you should be able to set it to true safely.