angular学习笔记(七)-迭代1
2024-08-26 22:54:24
本篇介绍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开始
最新文章
- JSP Servlet WEB生命周期
- Node.js NPM国内镜像
- 基于webpivottable做的透视表
- Toad for Oracle 授权权限
- MAC系统介绍
- [Ioi2007]Miners 矿工配餐(BZOJ1806)
- iOS源码博文集锦1
- IIS 服务或万维网公布服务,或者依赖这 服务可能在启动期间错误发生或者已禁用
- Eclipse安装Gradle插件
- 第十节:委托和事件(2)(泛型委托、Func和Action、事件及与委托的比较)
- 阿里字体css代码引入方法
- JSP页面分页显示数据
- Leeetcode--581. Shortest Unsorted Continuous Subarray
- Web开发.net framework 类库中必须掌握的命名空间(或者类)【转】
- [Node.js] 06 - Multi-thread and process module
- 转 阿里Dubbo疯狂更新,关Spring Cloud什么事?
- Structs hibernate spring=ssh简介
- struts2 动态Action
- javascript dom 操作详解 js加强
- Windchill 预览效果偏向左边
热门文章
- php之快速入门学习-9(switch)
- Java从零开始学三十七(JAVA IO- 二进制文件读写)
- 算法笔记_188:历届试题 危险系数(Java)
- 使用 C# 开发智能手机软件:推箱子(十二)
- 使用autoconfig
- exception is the version of xbean.jar correct
- myeclipse debug不显示变量值解决的方法
- 【Python】学习笔记六:循环
- [Done]ftp使用小结
- ValueError: Expecting property name: line 1 column 1 (char 1)