读取服务器json数据,get方式
<body> <div ng-app="Home"> <div ng-controller="httpTest"> 展示http服务 <p ng-repeat="name in names">{{name.name}}</p> </div> </div> </body> <script type="text/javascript"> //实例化应用对象,参数:模块名,空数组 var app=angular.module("Home",[]); //测试$http app.controller("httpTest",function($scope,$http){ $http.get("api.php").then(function(res){ console.log(res); var names=res.data.list; $scope.names=names; }); }); </script>
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/12711.html