I am posting some data to a php
page from angularjs
controller using the $http
method as shown below.
$scope.login = function(){
var data = {
'username' : $scope.username,
'password' : $scope.password
};
$http.post('login.php', data).success(function(response){
console.log(response);
});
};
I know I can retrieve this data in php
using :
$postdata = json_decode(file_get_contents('php://input'), true);
But I was wondering if there is better way in angularjs
so I could use the simple $_POST
in php
to retrieve the data.
In jQuery
we could just simply use $.post
and those are available for php
in $_POST
. Why for angularjs
that is not that simple.
Is there any way to populate $_POST
of php
when we do a $http
post
request in angularjs
. Please help.