0
我正在嘗試構建自定義日曆。還有很多事情要做,但我在這方面的問題是如何在Angular2組件中的HTML模板中實現一個計數器。更具體地:在Angular2組件的HTML模板中實現計數器
<div class="container">
<table class="table table-bordered">
<tbody>
<tr *ngFor="let w of weeks">
<td *ngFor="let d of days">
<ng-container *ngIf="(day_count <= monthLength && (w > 1 || d >= firstDayOfMonth))">
{{ day_count }}
// On this point, I want "day_count = day_count + 1"...
</ng-container>
</td>
</tr>
</tbody>
</table>
</div>
關於上述變量:
weeks = [1,2,3,4,5,6];
days = [0,1,2,3,4,5,6];
monthLength = 28 or 29 or 30 or 31
firstDayOfMonth = from 0 to 6
變量「DAY_COUNT」是變量負責顯示該月的每個日期。最初,它必須是1,然後增加1等,直到達到monthLength。那麼,我怎樣才能使這個實現?
你不能只用另一個'ngFor'循環嗎? – jonrsharpe