Reputation:
I have the following code:
<td>
<span data-ng-repeat="question in row.questions">{{ question.questionId }},</span>
</td>
This iterates through row.questions and gives an output looking like:
1,2,3,
My problem is with the last comma. Is there something that I could do to prevent the last comma from appearing. Note that I am currently using the 1.15 but if there was something new in the 1.2rc that would help I would be okay to use that.
Here is the HTML I currently have with the suggested solution:
<tr data-ng-show="grid.data.length > 0" data-ng-repeat="row in grid.data | orderBy:problemSortField.key:inverse">
<td>{{ row.problemId }}</td>
<td>
<span data-ng-repeat="question in row.questions">
{{ question.questionId }}<span data-ng-if="$last">,</span>
</span>
</td>
</tr>
Upvotes: 2
Views: 3440
Reputation: 43947
Use $last
:
<td>
<span data-ng-repeat="question in row.questions">
{{ question.questionId }}<span ng-if="!$last">,</span>
</span>
</td>
NOTE: ngIf
is a new directive added in v1.1.5.
Upvotes: 12