AngularJs Pass Data to $http.get request
AngularJs Pass data to $http.get request method – information in $http.get request method are passed in params that are announce to server. Here during this tutorial we tend to ar about to justify however you’ll post parameters victimisation the $http.get
request methodology to the server. we tend to ar about to justify this with syntax and example.
AngularJs Data Pass to $http.get request / Pass parameters
Here is example and syntax for passing parameters to the $http.get
request different method –
AngularJs Pass Data to $http.get request Method Syntax:
$http.get(url, { params: { params1: values1, params2:values2, params3:values3...... } });
Where url is the path to perform get request on server. params1, params2, params3 ..and values1, values2, values3.. are parameter and values that you want to post using the $http.get
method in angularjs.
AngularJs Pass Data to $http.get request Method Example:
$http.get("http://www.onlinecode.org/angularjs-moment-picker-date-time/", { params: { id: '116', name:'onlinecode', email:'ingo@onlinecode' } });
In the above example we have passed the name, id and email along with it is values using $http.get
request method. Thus we can post any data using the $http.get
method.
If we want to pass some data on using $http.get
method we can pass a options params on for get method of the $http service. This will be urlencode parameters.
Method 1 – AngularJs Pass Data to $http.get request
$http.get(url, { params: { query: 'hello world' } }
Method 1 – AngularJs Pass Data to $http request
$http({ url: url, method:'GET', params: { query:'Hello World' } })
But, the standars of http define the method of POST to send data to the server and GET is just to obtain data from it.
Method 1 – AngularJs Pass Data to post request
$http({ url: url, method:'POST', data: { query: 'Hello World' } })
You also like Angularjs Moment Picker AND Angularjs Ng-Bind with Example