Reputation: 2204
I'm trying to build a monthly calendar using Angular.js, and I can't seem to find a way of outputting expressions when conditions are satisfied.
<tr>
<td ng-repeat="date in dates">
{{date}}
</td>
{{'</tr><tr>' | if date.getDay() === 0}}
</tr>
Or
<tr>
<td ng-repeat="date in dates">
{{date}}
{{ if date.getDay() === 0 expr = '</tr><tr>' else expr = ''}}
</td>
{{expr}}
</tr>
How could I achieve this?
Thanks.
Upvotes: 0
Views: 222
Reputation: 4457
You could use the built in ng-if
directive.
<tr ng-if="date.getDay() === 0">
The better solution could be a nested ng-repeat
so you don't even have to do these checks. For instance:
<tr ng-repeat="week in weeks">
<td ng-repeat="day in week.days">...</td>
</td>
Upvotes: 2