获取网络

使用Angular获取JSON数据
<html ng-app="myApp">

    <head>
        <meta charset="utf-8" />
        <title>获取网络</title>
        <script type="text/javascript" src="libs/angular.min.js"></script>
        <script>
            var App = angular.module("myApp", []);
            App.controller("Democtrl", function($scope, $http) {
                $http({
                    method: "GET",
//                    获取本地  json 字符串
                    url: "package.json"
                    //                    正确的
                }).success(function(data) {
//                    看清楚是否获取的是否是    数组   还是    对象
                    //                    $scope.datas = data.records;
                    $scope.datas = data;
                    console.log($scope.datas);
                    //                    错误的
                }).error(function(data) {

                })
            });
        </script>
    </head>

    <body ng-controller="Democtrl">
        <center>
            <table border="1">
                <thead>
                    <tr style="background-color: yellow;">
                        <td><input type="checkbox" ng-model="selectAll" ng-click="selectAllFun()" /></td>
                        <td width="100px">aid</td>
                        <td width="100px">atitle</td>
                        <td width="230px">操作</td>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="a in datas">
                        <td><input type="checkbox" ng-model="a.state" /></td>
                        <td>{{a.id}}</td>
                        <td>{{a.title}}</td>
                        <!--删除-->
                        <td>
                            <button ng-click="del(a.id)">删除</button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </center>
    </body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值