Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
How to solve a typescript initialization issue in my Angular project?

I have an Angular project and I'm trying to define a variable with the following type:

navbarLinks: QueryList<ElementRef>;

but I get the following error:

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

30   navbarLinks: QueryList<ElementRef>;

Now, I don't want to use this as a solution:

navbarLinks!: QueryList<ElementRef>;

Is there any other way I can fix this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you really do not want to set a default value to this property you need to adjust your type to

navbarLinks?: QueryList<ElementRef>;

which is the same as

navbarLinks: QueryList<ElementRef> | undefined;

Another solution would be to give the property a default value. As I don't know what the QueryList<T> interface looks like, I can't really give you an example.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!