I am trying to display a table using Angular but it won't display. Is something wrong/missing? Code below. The table is in the source code as being there, but nothing is generated inside it. I'm new to Angular.
Front-end
<div ng-app="musicApp" ng-controller="musicCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.Name }}</td>
<td>{{ x.SongArtist }}</td>
<td>{{ x.SongAlbum }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('musicApp', []);
app.controller('musicCtrl', function($scope, $http) {
$http.get("http://rhys-bennett.uk/AIDc3391265/includes/formatjson.php")
.then(function (response) {$scope.names = response.records;});
});
</script>
PHP Back-end
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$result = $conn->query("SELECT song_name, song_artist, song_album FROM musictable");
$outp = "";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "") {$outp .= ",";}
$outp .= '{"Name":"' . $rs["song_name"] . '",';
$outp .= '"SongArtist":"' . $rs["song_artist"] . '",';
$outp .= '"SongAlbum":"'. $rs["song_album"] . '"}';
}
$outp ='{"records":['.$outp.']}';
$conn->close();
echo($outp);
?>