读取服务器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>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2021-08-15
  • 2021-10-19
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案