title: angularjs how to retrieve data from mysql and show in ng-select and ng-options
body: <p>i was trying to populate data in html form using ng-select and ng-options.but cannot figure it out.my code looks like this:</p>
  
  <pre><code>function get_areanames() {    
  $qry = mysql_query('SELECT * from tbl_area');
  $data = array();
  while($rows = mysql_fetch_array($qry))
  {
      $data[] = array(
                  "areaid"            =&gt; $rows['areaid'],
                  "areaname"     =&gt; $rows['areaname']
                  );
  }
  print_r(json_encode($data));
  return json_encode($data);  
  </code></pre>
  
  <p>}</p>
  
  <pre><code>$scope.get_areanames = function($scope,$http){
   $http.get("library/function.php?action=get_areanames").success(function(data)
  {
     $scope.areaname = data;  
  
  
  });
  }
  
  &lt;select class="form-control select2me" data-placeholder="Choose Area Name" name="areaname"  ng-model="areaname" required&gt; &lt;option&gt;&lt;/option&gt;&lt;/select&gt;
  </code></pre>