0
  <li
    class="list-group-item"
    *ngFor="let user of users.filter((x: any) => x.status.toLowerCase().startsWith('active')); let i = index">
    <div *ngIf="user.status == 'active'">
    {{ user.name }} | <a href="#" (click)="onSetToInactive(i)">Set to Inactive</a>
    </div>
  </li>

Users is defined as

users: {name: string, status: string}[] = [];

The error I get is

error NG5002: Parser Error: Unexpected token =, expected identifier, keyword, or string at column 35 in [let user of u
sers.filter((x: any) => x.status.toLowerCase().startsWith('active')); 

UPDATE--------------

<ul class="list-group">
  <li
    class="list-group-item"
    *ngFor="let user of users; let i = index">
    <ng-container *ngIf="user.status == 'active'">
    {{ user.name }} | <a href="#" (click)="onSetToInactive(i)">Set to Inactive</a>
    </ng-container>
  </li>
</ul>

It renders empty cells if I 'move' the users from active to inactive enter image description here

software is fun
  • 7,286
  • 18
  • 71
  • 129
  • Why not just call a function `onInit` that contains the new filtered users? – Mohamed Karkotly May 27 '22 at 13:23
  • It does work but see updated question – software is fun May 27 '22 at 13:28
  • Can we see the content of onSetToInactive and user object? or why dont you just pass `user` as argument like `onSetToInactive(user)` and execute inside fucntion `user.status = 'inactive'`. check this https://stackblitz.com/edit/angular-ivy-hsdfmc?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts – tony May 27 '22 at 13:44
  • onSetToInactive make sure you are creating a new array (this.users= [...old array, updated element]), because of JS mutability problem. Angular will not trigger change detection on the UI if you are just updating a property inside an element(you are not changing the reference of the "users" variable in the memory). Otherwise, you can manually run change detection by using ChangeDetectorRef. – Keryanie May 27 '22 at 13:45

0 Answers0