• angluarJs与后台交互get


    <!DOCTYPE html>
    <html lang="en" ng-app="myApp">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            *{margin: 0;
            padding: 0; list-style: none}
            .con{
                 408px;
                height: 300px;margin: 50px auto ;
                border: 1px solid red;  collapse: collapse      }
            .nav:after{
                content: ''; display: block; clear: both;
            }
            .nav li{
                float: left; 100px;
                height: 30px;text-align: center;
                line-height: 30px;
                border: 1px solid red;
            }
            #a1 .a1,#a2 .a2,#a3 .a3,#a4 .a4{
                background: aquamarine;
                color: #fff;
            }
        </style>
    </head>
    <body>
    <div class="con" ng-controller="cotr1" ng-init="active='a1'">
        <ul class="nav" id="{{active}}">
            <li ng-click="active='a1'" class="a1">热门</li>
            <li ng-click="active='a2'" class="a2">头条</li>
            <li ng-click="active='a3'" class="a3">财经</li>
            <li ng-click="active='a4'" class="a4">娱乐</li>
        </ul>
        <div ng-show="active=='a1'">
            <ul>
                <li ng-repeat="item in data.a1">
                    <a href="{{url}}">{{item.title}}</a>
                </li>
            </ul>
        </div>
        <div ng-show="active=='a2'">
            <ul>
                <li ng-repeat="item in data.a2">
                    <a href="{{url}}">{{item.title}}</a>
                </li>
            </ul>
        </div>
        <div ng-show="active=='a3'">
            <ul>
                <li ng-repeat="item in data.a3">
                    <a href="{{url}}">{{item.title}}</a>
                </li>
            </ul>
        </div>
        <div ng-show="active=='a4'">
            <ul>
                <li ng-repeat="item in data.a4">
                    <a href="{{url}}">{{item.title}}</a>
                </li>
            </ul>
        </div>
    
    </div>
    <script src="angular-1.3.0.js"></script>
    <script>
        var app=angular.module("myApp",[]);
        app.controller("cotr1",function ($scope,$http) {
          
            $http.get("http://qd.baidu.com/tgr/api/index.aspx?day=82&type=tabs").success(function (data) {
                $scope.data=data;
            })
        });
    </script>
    </body>
    </html>

    <!DOCTYPE html>
    <htmllang="en"ng-app="myApp">
    <head>
    <metacharset="UTF-8">
    <title>Title</title>
    <style>
    *{margin:0;
    padding:0; list-style: none}
    .con{
    width:408px;
    height:300px;margin:50pxauto;
    border:1px solid red; collapse: collapse }
    .nav:after{
    content:''; display: block; clear: both;
    }
    .nav li{
    float: left;width:100px;
    height:30px;text-align: center;
    line-height:30px;
    border:1px solid red;
    }
    #a1 .a1,#a2 .a2,#a3 .a3,#a4 .a4{
    background: aquamarine;
    color:#fff;
    }
    </style>
    </head>
    <body>
    <divclass="con"ng-controller="cotr1"ng-init="active='a1'">
    <ulclass="nav"id="{{active}}">
    <ling-click="active='a1'"class="a1">热门</li>
    <ling-click="active='a2'"class="a2">头条</li>
    <ling-click="active='a3'"class="a3">财经</li>
    <ling-click="active='a4'"class="a4">娱乐</li>
    </ul>
    <divng-show="active=='a1'">
    <ul>
    <ling-repeat="item in data.a1">
    <ahref="{{url}}">{{item.title}}</a>
    </li>
    </ul>
    </div>
    <divng-show="active=='a2'">
    <ul>
    <ling-repeat="item in data.a2">
    <ahref="{{url}}">{{item.title}}</a>
    </li>
    </ul>
    </div>
    <divng-show="active=='a3'">
    <ul>
    <ling-repeat="item in data.a3">
    <ahref="{{url}}">{{item.title}}</a>
    </li>
    </ul>
    </div>
    <divng-show="active=='a4'">
    <ul>
    <ling-repeat="item in data.a4">
    <ahref="{{url}}">{{item.title}}</a>
    </li>
    </ul>
    </div>

    </div>
    <scriptsrc="angular-1.3.0.js"></script>
    <script>
    var app=angular.module("myApp",[]);
    app.controller("cotr1",function($scope,$http){

    $http.get("http://qd.baidu.com/tgr/api/index.aspx?day=82&type=tabs").success(function(data){
    $scope.data=data;
    })
    });
    </script>
    </body>
    </html>

  • 相关阅读:
    [POJ1743]Musical Theme
    ubuntu qq
    Separate code and data contexts: an architectural approach to virtual text sharing
    Python3发送post请求,自动记住cookie
    python 异步协程
    豆瓣爬虫
    pandas 使用
    房天下爬虫
    计算英文文章词频的两种方法
    LOW版统计词频
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10413455.html
Copyright © 2020-2023  润新知