Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

385
Vistas
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" ??

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda