title: Passing variable from view to http post using AngularJS and PHP
body: <p>I am taking first steps with angular here and breaking my head about two stuff.
  the first is i cant pass variable from the view to http.post call.</p>
  
  <p>in this index.html <code>ng-click</code> passes the correct values:</p>
  
  <pre><code>&lt;tbody&gt;
      &lt;tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit"&gt;
         &lt;td&gt;&lt;a href="{{data.link}}" target="_blank"&gt;{{data.songName}}&lt;/td&gt;
         &lt;td&gt;{{data.artist}}&lt;/td&gt;
         &lt;td&gt;&lt;a ng-click="deleteSong(data.songName, data.artist, data.link)"&gt;&lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>and in app.js the deleSong function looks like this:</p>
  
  <pre><code>$scope.deleteSong = function($songName, $artist, $link) {
      // Posting data to php file
      $http({
          method  : 'POST',
          url     : 'ajax/deleteSong.php',
          data    : $scope.data, //forms user object
          headers : {'Content-Type': 'application/x-www-form-urlencoded'}
      })
          .success(function(data) {
  
              if (data.errors) {
                  // Showing errors.
                  $scope.errorSong= data.errors.song;
                  $scope.errorArtist= data.errors.artist;
                  $scope.errorLink= data.errors.link;
              } else {
                  $scope.message = data.message;
              }
          });
      $scope.user = null
  }
  </code></pre>
  
  <p>and finally , deleteSong.php looks like this:</p>
  
  <pre><code>&lt;?php
  include('../includes/config.php');
  
  $errors = array();
  $data = array();
  // Getting posted data and decodeing json
  $_POST = json_decode(file_get_contents('php://input'), true);
  
  $song = $_POST['song'];
  
  $query="DELETE FROM songs WHERE songName = '$song'";
  $mysqli-&gt;set_charset('utf8mb4');
  $result = $mysqli-&gt;query($query) or die($mysqli-&gt;error.__LINE__);
  
  echo $query;
  ?&gt;
  </code></pre>
  
  <p>When i click the delete song icon, the function get called but the response i get is this:</p>
  
  <p><code>DELETE FROM songs WHERE songName = ''</code></p>
  
  <p>any idea what am i missing and why is the query not getting the data i passed to <code>deleteSong.php</code>?</p>