Home > Blockchain >  viewChild declaration expected
viewChild declaration expected

Time:11-14

Hi I am new to angular while I am trying to learn rxjs , on following the tutorial i got this error, I tried many ways but not working anything.

previous error was 'error TS7008: Member '(Missing)' implicitly has an 'any' type.' and I changed the "tsconfig.json" strict =false. now I am getting this error on the picture I attached please help me to resolve

code part------

export class RxjsComponent implements OnInit {
  // agents: any = [];
  
  @ViewChild(validate);
  validate!:ElementRef;

error---------- Error: src/app/rxjs/rxjs.component.ts:12:23 - error TS1146: Declaration expected. enter image description here

CodePudding user response:

'validate' is the name which is passed in Component.html file within any tag which starts with #. like in

<p #validate></p>

You can try this :

@ViewChild('validate') !: ElementRef;

CodePudding user response:

@ViewChild('validate') validate: any

finally this works

  • Related