$http angular js service
- Encapsulates HTTP communication
GET, POST, PUT, DELETE - Can "ask" for $http inside a controller
Just add as another parameter to controller function - Always return a promise
A promise to deliver a value in the future.
example code for this
<script>
var PersonController = function($scope, $http){
$http.get('users/id/123')
.then(function(response){
$scope.data = response.data;
}
}
</script>
0 comments:
Post a Comment