json
[{"name":"name96","age":12},
{"name":"nam12","age":52},
{"name":"nam2556","age":82}]
html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<script type="text/javascript" src="js/angular.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http,$interval){
$http({
method:"get",
url:"myjson.json"
}).then(function success(response){
$scope.item = response.data;
},function error(){
$scope.name="error";
});
//获取系统时间
$interval(function(){
$scope.times=new Date().toLocaleTimeString();
});
});
</script>
<body ng-app="myApp" ng-controller="myCtrl">
<table border="1" cellspacing="1" cellpadding="10">
<tr ng-repeat="x in item">
<td>
{{x.name}}
</td>
<td>
{{x.age}}
</td>
</tr>
</table>
<p>{{times}}</p>
</body>
</html>
网友评论