Jane Angular Angular Ajax

Source: Internet
Author: User

Bottom line: They angular each stage of the framework's declaration cycle, and the general conventions focus on specific functions, which can be handled or replaced with each other.

1. function Subdivision Simple solution
$http Like jquery Ajax, Support promise
$http. Jsonp Cross-domain access, support for JSON data format only, no support for text, HTML and other formats
$httpProvider Mainly used in config, do http common settings
1 <label>JSONP instances, Http promise instances</label>2     <DivNg-controller= "Jsonpcontroller">3         <DivID= "Baidu">4HTTP promise: {{hpromise}}<P></P>5 Jsonp: {{jsp}}6         </Div>7     <Script>8     varmyApp=Angular.module ('myApp', []);9 Ten Myapp.controller ('Jsonpcontroller', function($scope, $http) { One $http. JSONP ("Https://api.github.com?callback=JSON_CALLBACK"). Success (function(data) { A $scope. JSP=data; -         }); -  the         varPromise=$http ({ - Method:'GET', - URL:'https://api.github.com' -         }); + promise.success (function(data, status, headers, config) { - $scope. Hpromise=Data.current_user_url; +  A         }); at Promise.error (function(data, status, headers, config) { - scope.hpromise= 'hpromise'; -         }); -  -     }); -     </Script> in     </Div> -  to     <P></P> +     <label>$httpProvider instances</label> -     <Pre> the angular.module (' myApp ', []) * . config (function ($httpProvider) { $ $httpProvider. Defaults.headersPanax Notoginseng . common[' x-requested-by '] = ' myangularapp '; - }); the     </Pre>

2. View the results of the operation online

Http://jimuyouyou.github.io/angular-bootstrap-rest-seed/examples/angular/8-ajax.html

3. Project Address

Github:https://github.com/jimuyouyou/angular-bootstrap-rest-seed

Jane Angular Angular Ajax

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.