Angular 13 ElementRef initialization error

yotube
0

Issue

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


Solution

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


Answered By - Naren Murali
Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top