zoukankan      html  css  js  c++  java
  • Angular 学习笔记——$http

    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <script src="angular.min.js"></script>
    <script>
        var m1 = angular.module('myApp',[]);
        m1.controller('may',['$scope','$http','$timeout',function ($scope,$http,$timeout){
            var timer = null;
            $scope.change = function (name){
                $timeout.cancel(timer);
    
                timer = $timeout(function (){
                    $http({
                        method:'JSONP',
                        url:'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+name+'&cb=JSON_CALLBACK'
                    }).success(function (data){
                        $scope.data = data.s;
                    })
                },500);
            }
        }])
    </script>
    </head>
    
    <body>
        <div ng-controller='may'>
            <input type='text' ng-model='name' ng-keyup="change(name)">
            <input type="button" value="search" ng-click="change(name)">
            <ul>
                <li ng-repeat='d in data'>{{d}}</li>
            </ul>
        </div>
    
    </body>
    </html>
  • 相关阅读:
    nyoj 17 单调递增最长子序列
    nyoj 18 The Triangle
    nyoj 712 探 寻 宝 藏
    nyoj 61传纸条(一)
    nyoj 269 VF
    nyoj 44 子串和
    nyoj 252 01串
    nyoj 42 一笔画问题
    nyoj 756 重建二叉树
    Table 样式设置
  • 原文地址:https://www.cnblogs.com/mayufo/p/5027112.html
Copyright © 2011-2022 走看看