AngularJs学习日记[8]:$http

php代码:

<?php 
echo'[ 
{ "Name" : "222Alfreds Futterkiste", "City" : "Berlin", "Country" : "Germany" },
{ "Name" : "121212Berglunds snabbk&ouml;p", "City" : "Lule&aring;", "Country" : "Sweden" },
{ "Name" : "Centro comercial Moctezuma", "City" : "M&eacute;xico D.F.", "Country" : "Mexico" },
{ "Name" : "Ernst Handel", "City" : "Graz", "Country" : "Austria" }, 
{ "Name" : "FISSA Fabrica Inter. Salchichas S.A.", "City" : "Madrid", "Country" : "Spain" }, 
{ "Name" : "Galer&iacute;a del gastr&oacute;nomo", "City" : "Barcelona", "Country" : "Spain" }
]'
?>

html代码:

<!DOCTYPE html>
<html>
<body>
	
<div ng-app="" ng-controller="customersController"> 

<ul>
  <li ng-repeat="x in names">
    {{ x.Name + ', ' + x.Country }}
  </li>
</ul>

</div>

<script type="text/javascript" src="angular.min.js"></script>
<script>
function customersController($scope,$http) {
    $http.get("1.php")
    .success(function(response) {$scope.names = response;});
}
</script>

</body>
</html>

效果截图:

AngularJs学习日记[8]:$http_第1张图片

你可能感兴趣的:(AngularJS,XMLhttpREquest)