I am trying to fetch some data from database but when i am returning the json encoded output to angular controller, it is not getting response data. It is showing blank. This is my controller
'use strict';
app.controller('customerController', ['$scope', '$http', function ($scope, $http) {
$http.get("data/getCustomers.php")
.success(function(data){
console.log(data);
//$scope.data = data;
})
.error(function() {
$scope.data = "error in fetching data";
});
}]);
console.log is not printing anything. it is only showing blank. Here is my code to fetch data
$results = $con->query("SELECT
c.id,
c.name as companyname,
c.address,
c.postcode,
c.city,
c.country,
c.contactnumber,
c.dateadded,
c.plan,
m.companyid,
m.name as naam,
m.email,
a.companyid,
a.livemode,
a.srmode,
a.paypal
FROM
company c
LEFT JOIN login m ON c.id = m.companyid
LEFT JOIN settings a ON c.id = a.companyid
");
$row_cnt = $results->num_rows;
$data = array();
if($row_cnt > 0){
while($result = $results->fetch_assoc()){
$data[] = $result;
}
}
echo json_encode($data);
How to get this json response and how to display using ng-repeat .
curlrequest to see the actual response ? Also maybe try addingheader('Content-type: application/json')even though it should work even without it.