Is it possible to have a shorthand local variable in ngFor?

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

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

The estimated hypothetical part: let agenda=userHasAgenda.agenda. Trying something like this, 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 "aliases"?

+6
source share
1 answer

No, according to this GitHub problem ( Support for assigning the result of the expression of a local variable in templates ), it is not supported, but there is hope:

December 14, 2016

, - .

NgFor : index, first, last, even odd

+2

Source: https://habr.com/ru/post/1015883/


All Articles