Send data with $http.post() in AngularJs
In AngularJs Controller
....
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
}
$http.post('http://5.project/posts',{category_id:11},config)
.then(function(response) {
vm.posts = response.data;
});
And to receive above category_id in php, we have to use following:
....
$params = json_decode(file_get_contents('php://input'),true);
print_r($params);