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

388
Visualizações
Is it possible to have a shorthand local variable in ngFor?

In Angular 2 ngFor, is it possible to declare a local (short-hand) variable? I mean something like this, but I am not sure about the syntax:

<li *ngFor="let userHasAgenda of agendas | async;
    let agenda=userHasAgenda.agenda">

The hypothetical part in question: let agenda=userHasAgenda.agenda. Trying something like that, angular gives me: Parser Error: Unexpected token ., expected identifier, keyword, or string at column 43 in [let uha of agendas | async; let agenda=uha.agenda;]

Edit 1: For comparison, I know this is possible, for example, with index/first/last:

<li *ngFor="let task of tasks | async;
    let i = index;
    let isFirst = first;
    let isLast = last;"

But is it allowed to have custom "aliased variables" ??

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

No, according to this GitHub issue (Support assigning expression result to local variable within templates), it isn't supported, but there is hope:

14 Dec 2016

Probably something we can consider at a later point according to usage needs.

For now, we have to stick to the five NgFor local variables: index, first, last, even and odd

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