美文网首页
An_form服务应用

An_form服务应用

作者: android_en | 来源:发表于2017-09-21 20:13 被阅读10次

    json

    [{"name":"name96","age":12},
    {"name":"nam12","age":52},
    {"name":"nam2556","age":82}]
    
    

    html

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <script type="text/javascript" src="js/angular.js" ></script>
        <script>
            var app=angular.module("myApp",[]);
            app.controller("myCtrl",function($scope,$http,$interval){
                $http({
                        method:"get",
                        url:"myjson.json"
                    }).then(function success(response){
                        $scope.item = response.data;
                    },function error(){
                        $scope.name="error";
                    });
                //获取系统时间
                $interval(function(){
                    $scope.times=new Date().toLocaleTimeString();
                });
            });
        </script>
        <body ng-app="myApp" ng-controller="myCtrl">
            <table border="1" cellspacing="1" cellpadding="10">
                <tr ng-repeat="x in item">
                    <td>
                        {{x.name}}
                    </td>
                    <td>
                        {{x.age}}
                    </td>
                </tr>
            </table>
            <p>{{times}}</p>
        </body>
    </html>
    
    

    相关文章

      网友评论

          本文标题:An_form服务应用

          本文链接:https://www.haomeiwen.com/subject/owmtextx.html