码迷,mamicode.com
首页 > Web开发 > 详细

利用$http获取在服务器的json数据

时间:2016-06-23 22:17:08      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

以下是存储在web服务器上的 JSON 文件:

http://www.runoob.com/try/angularjs/data/Customers_JSON.php

{
"records":[
{"name":‘yan1‘,"age":‘11‘,"sex":‘man‘},
{"name":‘yan2‘,"age":‘12‘,"sex":‘man‘},
{"name":‘yan3‘,"age":‘13‘,"sex":‘man‘},
{"name":‘yan4‘,"age":‘14‘,"sex":‘man‘},
]

}

  

<div ng-app="myApp" ng-controller="customersCtrl"> 

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

</div>

<script>
var app = angular.module(‘myApp‘, []);
app.controller(‘customersCtrl‘, function($scope, $http) {
    $http.get("http://www.runoob.com/try/angularjs/data/Customers_JSON.php")
    .success(function(response) {$scope.names = response.records;});
});
</script>

  

利用$http获取在服务器的json数据

标签:

原文地址:http://www.cnblogs.com/coding4/p/5612287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!