Home > Back-end >  Angular 13 ElementRef initialization error
Angular 13 ElementRef initialization error

Time:08-24

hello i am having issues initializing viewchild elementRef this always work fine for me but in angular 13 i am having an error message


 @ViewChild("text", { static: true }) text : ElementRef;

Property 'text' has no initializer and is not definitely assigned in the constructor

Thanks

CodePudding user response:

Change it to.

@ViewChild("text", { static: true }) text!: ElementRef;

Read more

  1. Property 'text' has no initializer and is not definitely assigned in the constructor
  2. Not null assertion operator
  • Related