Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

305
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda