0

Angular @ViewChild Error: Expected 2 arguments, but got 1. ts (2554).

i am a new learner and right now i am stuck at a point where i dont understand why am i getting this error to my export class @ViewChild('namInput') this line of code is then underlined with RED color, and i can't seem to fix this. i also did an update but it is still the same. can someone plz help me out?

code example :

import { Component, OnInit, ElementRef, ViewChild} from '@angular/core';

export class ShoppingEditComponent implements OnInit {

  • @ViewChild('nameInput') nameInputRef: ElementRef;
  • @ViewChild('amountInput') amountInputRef: ElementRef;
khan
  • 1
  • 1

1 Answers1

1

@ViewChild decorator have made options argument required in the Angular 8 version.

Here is an example:

    @ViewChild('nameInput', { static: false }) nameInputRef: ElementRef;

or ofcourse you can set it to True if you need.

Jackie
  • 327
  • 2
  • 13