Angularjs $http Services

Source: Internet
Author: User

<! DOCTYPE html>"myApp">"Content-type"Content="text/html; Charset=utf-8"><title> Untitled Document </title><script src="Angular.min.js"></script><script>Angularjs is an independent framework that can be used without jquery.ng services:--$scope--$watch: Sub-service of scope--$apply: Sub-service of scope--$rootScope--$timeout--$interval--$filter--$http: Similar to Ajax, this is a request that Angularjs comes from in a different way than jquery. varM1 = Angular.module ('myApp', []); M1.controller ('Aaa',['$scope','$http', function ($scope, $http) {$http ({method:'GET', URL:'data.php'}). Success (function (Data,state,headers,config) {console.log (state);//request successfully returned 200 status}). Error (function (data) {Console.log (data);            }); $http.Get('data.php'). Success (function (Data,state,headers,config) {console.log (data);    }); }]);</script>"Aaa"></div></body>
<! DOCTYPE html>"myApp">"Content-type"Content="text/html; Charset=utf-8"><title> Untitled Document </title><script src="Angular.min.js"></script><script>varM1 = Angular.module ('myApp', []); M1.controller ('Aaa',['$scope','$http','$timeout', function ($scope, $http, $timeout) {varTimer =NULL; $scope. Data= []; $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) {//console.log (data);$scope. Data =Data.s;                }); }, -);                }; }]);</script>"Aaa"> <input type="text"Ng-model="name"ng-keyup="Change (name)"> <input type="Button"ng-click="Change (name)"Value="Search"> <ul> <li ng-repeat="d in Data">{{d}}</li> </ul></div></body>

Angularjs $http Services

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.