I have made some web apps with php and angularjs. The way I do it is the following:
When bringing data from php to an array in angular and html.
I can have this script in php:
<?php
require_once '../config.php';
$id = $_GET['id_project'];
$query = "SELECT *
FROM `activity_planned` as A,`user` as U
WHERE A.id_user = U.id_user and A.id_project = $id";
$answer = $mysqli->query($query);
$result = array();
foreach( $answer as $row ){
array_push($result,$row);
}
echo $json_response = json_encode($result);
?>
Then, the function in angular that calls this script uses the $http service:
$scope.getActivities = function() {
$http({
url: './scripts/getters/get-activities-by-project-id.php',
method: 'GET',
params: {
id_project: $stateParams.projectId
}
})
.success( function( response ) {
$scope.activities = response;
});
};
By having the ng-repeat directive in html, all these "activities" will be displayed:
<div ng-repeat="item in activities track by $index">
<p>{{item.id}}</p>
<p>{{item.name}}</p>
</div>
You will need to encode into json the array and echo the result in php.
This "echo" will function as a return, and the response parameter in the $scope function will receive the data from it.