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>