Browse Source

ngIf 將元素list移至 ng-template

master
HarveyChou 2 years ago
parent
commit
aa2d25fae5
  1. 9
      src/app/app.component.html

9
src/app/app.component.html

@ -1,10 +1,13 @@
<button type="button" (click)="onLoad()">載入資料</button>
<button type="button" (click)="onClear()">清除資料</button>
<div *ngIf="tasks.length >= 1; else empty">
<app-task *ngFor="let task of tasks; let odd = odd" [class.odd]="odd" [task]="task"></app-task>
</div>
<div *ngIf="tasks.length === 0; then empty else list"></div>
<ng-template #empty>
<div class="data-empty">無待辦事項</div>
</ng-template>
<ng-template #list>
<app-task *ngFor="let task of tasks; let odd=odd" [class.odd]="odd"
[task] = "task"></app-task>
</ng-template>
Loading…
Cancel
Save