Click here to Skip to main content
15,924,036 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi guys
My Que is that why we use http request to get data in angular??
whats that http?please explain in detail

What I have tried:

I search google but did not get it .
Posted
Updated 16-May-17 22:28pm
Comments
Richard MacCutchan 17-May-17 4:10am    
You searched google for HTTP, and got nothing?
CPallini 17-May-17 4:27am    
That puzzles me too.

As you might now angular is a client-side framework which means it operates in user's browser. So it's not the best idea to leave complex computations to user's computational capability. Also, you might need access to data stored in some persistent storage on a remote server.
So the core idea is that you leave data storage and complex computation to a remote server, whereas angular just handles the presentation of your data.
That's why you need a way for angular to communicate with a remote server. And you use
JavaScript
$http
for this.
Natural way for server is to provide some REST API wich your angular app queries for data as following
JavaScript
$http({
  method: 'GET',
  url: '/yourApiEndpoint'
}).then(function successCallback(response) {
    // this callback will be called asynchronously
    // when the response is available
  }, function errorCallback(response) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900