angularjs - how to send data with ever $http post -
i wanted able send ipaddress
every $http.post() that's being sent backend without manually mentioning every time send post. how in angular ? found out there $ajax.setup
in jquery please provide me example doing similar in angular js?
$http.post('actions.php', {ip: ipaddress, data: add}) .then(function (response) { alert("post sent") });
you can set ipaddress
in http headers in runtime this:
module.run(function($http) { $http.defaults.headers.common.ipaddress = ipaddress; });
or add http headers requests,these defaults can configured accessing $httpprovider.defaults.headers
configuration object, contains default configuration.
for more info check setting http headers
section of $http
service on angular docs.
Comments
Post a Comment