I've been following this tutorial and have the following controller:
(function (app) {
var MusicListController = function ($scope, $http) {
$http.get("/api/Musics").then(function (data) {
$scope.musics = data;
},function (response){}
);
};
app.controller("MusicListController", MusicListController);
}(angular.module("theMusic")));
module:
(function () {
var app = angular.module('theMusic', []);
}());
and html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Music App</title>
<script src="../../Scripts/angular.js"></script>
<script src="../../Scripts/jquery-1.10.2.js"></script>
<link href="../../Content/Site.css" rel="stylesheet" />
<link href="../../Content/bootstrap.css" rel="stylesheet"/>
<script src="../../Scripts/bootstrap.js"></script>
<script src="../Scripts/theMusic.js"></script>
<script src="../Scripts/MusicListController.js"></script>
</head>
<body>
<div ng-app="theMusic">
<div ng-controller="MusicListController">
<table class="table table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Singers</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="music in musics">
<td>{{music.Title}}</td>
<td>{{music.Singers}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
It's supposed to display the results of an API request but currently all that is displayed is an empty table. I suspect my problem lies somewhere with my $http.get.then
function as the tutorial used what seems to be a deprecated $http.get.success
and I looked up the new way of doing it.
If I go to (localhost)/api/musics while debugging it does return the XML file with the data in it.
Could someone help?
Thanks