http

来源:互联网 发布:干部动议知乎 编辑:程序博客网 时间:2024/06/05 23:51
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="../angular/angular.js"></script>
        <script>
            var app=angular.module("myapp",[]);            
            app.controller("myctrl",function($scope,$http){            
            $http(
                {
                    methed:"get",
                    url:"haha.json"
                }
            ).then(
                function cg(s){
                    $scope.users=s.data;
                },
                function sb(){
                    $scope.users=null;
                }
            );            
            });    
        </script>
        <style>
            table tr:nth-child(odd){
                background-color:lightgreen;
            }
            table tr:nth-child(even){
                background-color:hotpink;
            }
        </style>
    </head>
    <body ng-app="myapp" ng-controller="myctrl">
            <center>
            <h3>我的用户表</h3>
            <table border="1px solide blue" cellpadding="10" cellspacing="0">
                <thead>
                    <tr>
                        <th>用户名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="user in users">
                        <td>{{user.name}}</td>
                        <td>{{user.age}}</td>
                        <td>{{user.sex}}</td>
                        <td><button ng-click="delete($index)">删除</button></td>
                    </tr>
                </tbody>
            </table>
        </center>
        
    </body>
</html>

原创粉丝点击