Filtering items by value inside ngFor without writing Pipes

Use a filter function to filter the data:

filterFunction(allButtons): any[] {  
    return allButtons.filter(buttom => buttom !== this.mode);
}

and in the template:

<button *ngFor="let othermode of filterFunction(modes)">
  {{ othermode }}
</button>

To filter objects, I recommend using existing component. See this thread:

::LINK EDITED::

https://stackblitz.com/edit/angular-ivy-wngx-filter

https://stackblitz.com/edit/article-demo


You can use :

<ng-container *ngFor="let othermode of modes">
  <button *ngIf="othermode!=mode">
    {{ othermode }}
  </button>
</ng-container>

Tags:

Angular

Ngfor