<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>$http</title>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){
$http({
method:"get",//请求路径
url:"myJson.json"//请求的json串 自己写的json串
}).then(function zhengque(response){
//请求正确
$scope.student=response.data;
},function cuowu(){
//请求错误
alert("错误");
});
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="s in student">姓名:{{s.name}}</li>
</ul>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>$http</title>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){
$http({
method:"get",//请求路径
url:"myJson.json"//请求的json串 自己写的json串
}).then(function zhengque(response){
//请求正确
$scope.student=response.data;
},function cuowu(){
//请求错误
alert("错误");
});
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="s in student">姓名:{{s.name}}</li>
</ul>
</body>
</html>