服务请求数据

来源:互联网 发布:淘宝托管真的有用吗 编辑:程序博客网 时间:2024/05/15 07:21
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="../js/angular.js" ></script>
        <script>
            var app = angular.module("myApp",[]);
            app.controller("myCtrl",function($scope,$http){
                //$scope.haha = 3;
                $http({//请求参数
                    method:"get",
                    url:"myJson.json"
                }).then(function success(response){
                    console.log(response);
                    console.log(response.data);
                    $scope.arr = response;
                    $scope.name = response.data[2].name;
                },function error(){
                    $scope.name = "error";
                });
            });
            
        </script>
    </head>
    <body ng-app="myApp" ng-controller="myCtrl">
        <!--{{arr}}-->
        <ul ng-repeat="user in arr.data">
            <p>姓名:{{user.name}},年龄:{{user.age}},性别:{{user.sex}}</p>
        </ul>
    </body>
</html>

原创粉丝点击