Since this question is quite old and AngularJS had had time to evolve since then, this can now be easily achieved using:
<li ng-repeat="record in records" ng-bind="record + ($last ? '' : ', ')"></li>
.
Note that I'm using ngBind
instead of interpolation {{ }}
as it's much more performant: ngBind
will only run when the passed value does actually change. The brackets {{ }}
, on the other hand, will be dirty checked and refreshed in every $digest, even if it's not necessary. Source: here, here and here.
angular_x000D_
.module('myApp', [])_x000D_
.controller('MyCtrl', ['$scope',_x000D_
function($scope) {_x000D_
$scope.records = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];_x000D_
}_x000D_
]);
_x000D_
li {_x000D_
display: inline-block;_x000D_
}
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>_x000D_
<div ng-app="myApp" ng-controller="MyCtrl">_x000D_
<ul>_x000D_
<li ng-repeat="record in records" ng-bind="record + ($last ? '' : ', ')"></li>_x000D_
</ul>_x000D_
</div>
_x000D_
On a final note, all of the solutions here work and are valid to this day. I'm really found to those which involve CSS as this is more of a presentation issue.