I am sending some data to the page phpfrom the controller angularjsusing the method $httpas 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 that I can get this data in phpusing:
$postdata = json_decode(file_get_contents('php://input'), true);
But I was wondering if there is a better way to angularjs, so I could use easy- $_POSTin phpto extract the data.
In jQuerywe could just use $.post, and they are available for phpin $_POST. Why angularjsis it not so simple. Is there a way to fill $_POSTout phpwhen we make a request $http postto angularjs. Please, help.