1. 程式人生 > >angular用ng-repeat批量處理資料

angular用ng-repeat批量處理資料

一般用ul li 裡面寫一堆資料,如果資料是json資料就可以用ng-repeat處理。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="day2/src/angular.js"></script>
		<style type="text/css">
			
			
		</style>
	</head>
	<body>
		
		<div ng-app="fristApp">
			<div ng-controller="fristController">
				
				<ul>
					<li ng-repeat="p in person">
						{{p.age}}
						{{p.name}}
					</li>
				</ul>
			
			</div>
			
		</div>
	</body>
	<script type="text/javascript">
		var myApp = angular.module('fristApp',[]);
		myApp.controller('fristController',function($scope){
			
			$scope.person = [{name:'zhangsan',age:30},{name:'zhangsan',age:30},{name:'zhangsan',age:30}];
			
		})
	</script>
</html>