您的位置:首页 > Web前端 > AngularJS

angular学习日志07 ng-repeat

2015-12-28 09:50 736 查看
<!DOCTYPE html>

<html lang="en" ng-app="start">

<head>
<meta charset="UTF-8">
<title>ngRepeat</title>
<script type="text/javascript" src="js/angular.min.js"></script>

</head>

<body ng-controller="StudentListController">
<ul>
<li ng-repeat="student in students">
<span>{{$index+1}}</span>
<a href="/student/view/{{student.id}}">{{student.name}}</a>
</li>
</ul>
<button ng-click="insertTom()">Insert</button>

<script type="text/javascript">
angular.module('start',[])
.controller('StudentListController',function($scope){
$scope.students=[{name:"张三",id:"1"},
{name:"李四",id:"2"},
{name:"王二",id:"3"}]
$scope.insertTom=function(){
$scope.students.splice(1,0,{name:"王二",id:"4"})

}
})

</script>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: