0

I have:

<mat-toolbar-row *ngFor="let idp of Idps | async; last as isLast">

and I need to access the length of it for these:

 <button [disabled]="(Idps| async)?.length===1" [ngClass]="{'disabledBtn': !(Idps | async)?.length > 1}"

this sadly does not work, I managed to make that syntax work only here:

{{ (Idps | async)?.length }}

if I put this in my HTML, it will show on screen the length, but I cannot find the right syntax to use for my [disabled] and [ngClass] tags

1 Answer 1

5

Use local variable from NgForOf directive ("count")

<mat-toolbar-row *ngFor="let idp of Idps | async; last as isLast; count as count">

Here you can find all the variables available for NgForOf directive

Sign up to request clarification or add additional context in comments.

1 Comment

It worth to add that full list of available variables can be found at angular.io/api/common/NgForOf#local-variables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.