I am really new to Angular. I am trying to pass a variable to php but the response is " Notice: Trying to get property of non-object" and null for the array.
js file:
var myData = {
fruit1: 'apple',
fruit2: 'banana'
};
$http({
url: "test.php",
method: "POST",
headers : { 'Content-Type': 'application/json' },
data: myData
}).success(function(data, status, headers, config) {
$scope.data = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
php file:
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$data = $request->myData;
var_dump($data);