本篇介绍angular中元素的迭代:

<!DOCTYPE html>
<html ng-app>
<head>
<title>4.1.迭代</title>
<meta charset="utf-8">
<script src="../angular.js"></script>
<script src="script.js"></script>
</head>
<body>
<ul ng-controller="StudentList">
<li ng-repeat="student in students">
<span class="index">{{$index+1}}</span><span class="name"><a href="/student/view/{{student.id}}" class="name">{{student.name}}</a></span><span
class="score">{{student.score}}</span>
</li>
</ul>
</body>
</html>
function StudentList ($scope){
$scope.students = [{"name":"code_bunny","score":"100","id":"001"},{"name":"white_bunny","score":"90","id":"002"},{"name":"black_bunny","score":"80","id":"003"}]
}
ng-repeat="student in students

使用ng-repeat属性来迭代当前元素,其中
in 之后的students,是当前作用域下的students变量
in之前的student是自己取的名字,作为下面的{{}}中当前被循环到的数据的名字.
$index是迭代的索引值,表示当前迭代到第几条了.从0开始

最新文章

  1. JSP Servlet WEB生命周期
  2. Node.js NPM国内镜像
  3. 基于webpivottable做的透视表
  4. Toad for Oracle 授权权限
  5. MAC系统介绍
  6. [Ioi2007]Miners 矿工配餐(BZOJ1806)
  7. iOS源码博文集锦1
  8. IIS 服务或万维网公布服务,或者依赖这 服务可能在启动期间错误发生或者已禁用
  9. Eclipse安装Gradle插件
  10. 第十节:委托和事件(2)(泛型委托、Func和Action、事件及与委托的比较)
  11. 阿里字体css代码引入方法
  12. JSP页面分页显示数据
  13. Leeetcode--581. Shortest Unsorted Continuous Subarray
  14. Web开发.net framework 类库中必须掌握的命名空间(或者类)【转】
  15. [Node.js] 06 - Multi-thread and process module
  16. 转 阿里Dubbo疯狂更新,关Spring Cloud什么事?
  17. Structs hibernate spring=ssh简介
  18. struts2 动态Action
  19. javascript dom 操作详解 js加强
  20. Windchill 预览效果偏向左边

热门文章

  1. php之快速入门学习-9(switch)
  2. Java从零开始学三十七(JAVA IO- 二进制文件读写)
  3. 算法笔记_188:历届试题 危险系数(Java)
  4. 使用 C# 开发智能手机软件:推箱子(十二)
  5. 使用autoconfig
  6. exception is the version of xbean.jar correct
  7. myeclipse debug不显示变量值解决的方法
  8. 【Python】学习笔记六:循环
  9. [Done]ftp使用小结
  10. ValueError: Expecting property name: line 1 column 1 (char 1)