本篇文章主要介绍了AngularJS ng-repeat遍历输出的用法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
AngularJS ng-repeat遍历输出的用法,最近需要用,就顺便发到随笔上了
<title>ng-repeat directive</title> <table> <caption>我的购物车</caption><tr> <th>序号</th><th>商品</th><th>单价</th><th>数量</th><th>金额</th><th>操作</th></tr><tr> <td>{{$index + 1}}</td><td>{{item.name}}</td><td>{{item.price | currency}}</td><td></td><td>{{item.quantity * item.price | currency}}</td><td> <button>Remove</button></td></tr></table>
ng-repeat指令生命在需要循环内容的元素上,items和控制器上的变量名对应,来源gao($daima.com搞@代@#码网item是为数组中单个对象起的别名。
$index可以返回当前引用对象的序号,从0开始,另外还有$first、$middle、$last可以返回布尔值,用于告诉你
当前元素是否是集合中的第一个中间的最后一个元素。
以上就是AngularJS ng-repeat遍历输出的用法的详细内容,更多请关注gaodaima搞代码网其它相关文章!