title: Passing data from Angularjs to PHP
body: <p>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.</p>
  
  <p>js file:</p>
  
  <pre><code>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;
  });
  </code></pre>
  
  <p>php file:</p>
  
  <pre><code>$postdata = file_get_contents("php://input");
  $request = json_decode($postdata);
  $data = $request-&gt;myData;
  
  var_dump($data);
  </code></pre>