0

I am currently creating a @viewChild component, tabs in my app. However, upon inserting the following lines:

@ViewChild('tabs') tabs: IonTabs; 

I am facing an error 'Expected 2 arguments, but got 1.'

Please helps. Thks!

speedie
  • 82
  • 10

2 Answers2

3

Just found the error.

Insert the new line below:

@ViewChild('tabs', {static: true}) tabs: IonTabs;

Hopes this helps anyone !

kvetis
  • 6,682
  • 1
  • 28
  • 48
speedie
  • 82
  • 10
2

You have to configure the static property in Metadata Properties (From Angular 8 onwards).

@ViewChild('tabs', {static: false}) tabs: IonTabs; 

static property should be set true to resolve query results before change detection runs and false for depending on binding resolution (Structural directives *ngIf, *ngFor,...) for query resolution.

{static: false} will be used in most cases ensuring that query will be resolved after change detection runs.

The {static: false} is going to be the default fallback in Angular 9.

You can read more here: https://angular.io/api/core/ViewChild#description