AngularJS AJAX - $http
$http is an AngularJS service for reading data from remote servers.
AngularJS $http
The AngularJS $http service makes a request to the server, and returns a response.
Methods
The example above uses the .get method of the $http service.
The .get method is a shortcut method of the $http service. There are several shortcut methods:
.delete()
.get()
.head()
.jsonp()
.patch()
.post()
.put()
The methods above are all shortcuts of calling the $http service:
The example above executes the $http service with an object as an argument. The object is specifying the HTTP method, the url, what to do on success, and what to do on failure.
$http is an AngularJS service for reading data from remote servers.
AngularJS $http
The AngularJS $http service makes a request to the server, and returns a response.
<div ng-app="myApp" ng-controller="myCtrl">
<p>Today's welcome message is:</p>
<h1>{{myWelcome}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("welcome.htm")
.then(function(response) {
$scope.myWelcome = response.data;
});
});
</script>
Methods
The example above uses the .get method of the $http service.
The .get method is a shortcut method of the $http service. There are several shortcut methods:
.delete()
.get()
.head()
.jsonp()
.patch()
.post()
.put()
The methods above are all shortcuts of calling the $http service:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http({
method : "GET",
url : "welcome.htm"
}).then(function mySucces(response) {
$scope.myWelcome = response.data;
}, function myError(response) {
$scope.myWelcome = response.statusText;
});
});
The example above executes the $http service with an object as an argument. The object is specifying the HTTP method, the url, what to do on success, and what to do on failure.
Thanks for sharing, nice post!
ReplyDeleteTìm hiểu http://mayduavong.me/nen-mua-may-dua-vong-tu-dong-loai-nao-tot-nhat-gia-bao-nhieu/ và địa chỉ uy tín tại Hà Nội và TP.HCM bán http://anthaison.vn/sp/may-dua-vong-tu-dong-ts/ máy đưa võng chất lượng nhất, pediakid d3 có tốt không nên dùng cho trẻ mấy tháng tuổi, siro hỗ trợ tiêu hóa Pediakid Transit Doux cho trẻ có tốt không, siro tăng cường trí não cho trẻ pediakid omega 3 có tốt không có tốt không, bột uống pediakid tăng chiều cao có tốt không, hay siro nào tốt cho trẻ biếng ăn kích thích trẻ ăn ngon.