Élément d'affichage avec NG-Template

<!-- How to display one element with ng-template (also applies to one or more elements) -->

<div class="button-group">
  <ng-template [ngIf]="tableSettings.selection.selected.length > 0">
        <button mat-button
          class="mat-button"
          (click)="callMethod()">
          Chop Fruit
        </button>
      </ng-template>
   <button mat-button>Some other element</button>
</div>

<!-- The below will NOT work: -->
<!-- ngIf must be in ng-template in order to work properly -->

<div class="button-group">
  <ng-template>
        <button mat-button
          *ngIf="tableSettings.selection.selected.length > 0"
          class="mat-button"
          (click)="callMethod()">
          Chop Fruit
        </button>
      </ng-template>
   <button mat-button>Some other element</button>
</div>
Banana in Transit