title: Not able to call a method of PHP using $http.get in Angular JS
body: <p>I'm new to Angular JS. I'm able to call a php file and get the data. But, now the scenario is that I need to call a particular method from a php and get the data using "$http.get". Take a look at my code, whether I'm calling the method in the correct way or not?</p>
  
  <h2>Angular Code</h2>
  
  <pre><code>    // Ajax call for listing countries.
      var countryPromise = $http.get("ListData.php/getCountries()");
      // Create global users array.
      $scope.countriesArray = [];
  
      countryPromise.success(function(data, status, headers, config) {
          for(index in data) {
              alert(data[index].name);
              $scope.countriesArray.push({
                  id:data[index].id,
                  name:data[index].name                   
              });
          }
      });
      countryPromise.error(function(data, status, headers, config) {
          alert("Loading countries failed!");
      });
  </code></pre>
  
  <h2>PHP</h2>
  
  <pre><code>&lt;?php
  class ListData
  {
  function __construct() {
  
      // credentials of MySql database.
      $username = "root";
      $password = "admin";
      $hostname = "localhost"; 
  
      $countryData = array();
      //connection to the database
      $dbhandle = mysql_connect($hostname, $username, $password)
        or die("Unable to connect to MySQL");
  
      $selected = mysql_select_db("Angular",$dbhandle)
      or die("Could not select Angular");
  }
  public function getCountries() {
  
      //execute the SQL query and return records
      $result = mysql_query("SELECT id,name FROM Country");
  
      //fetch tha data from the database
      while ($row = mysql_fetch_array($result)) {
  
          $id = $row{'id'};
          $name = $row{'name'};
          $countryData[] = array('id' =&gt; $id, 'name' =&gt; $name);
      }
      echo json_encode($countryData); 
  }
  </code></pre>
  
  <p>}
  ?></p>