Reputation: 3
I am trying to load in a list of "donors" for my angular application. I get the data from an API, but I doesn't work the way I want it to. I get this error:
$resourceProvider <- $resource <- DonorerCtrl
In my DonorerCtrl class I have the following code:
angular.module("testApp").controller("DonorerCtrl",
function($scope, $http, $resource) {
console.log("Test fra donorerCtrl");
$scope.donorerResource = $resource("http://bloodadmin.cloudapp.net/api/users/:donorid"),
{id: "@donorid"}, { update: {method: "PUT"}};
$scope.donorerVisits = $scope.donorerResource.query();
$http (
{
method: "GET",
url: "http://bloodadmin.cloudapp.net/api/donors"
}).success(function(data) {
$scope.donorerVisits = data;
}).error(function() {
alert("error");
});
$scope.donorerVisits = [];
});
I try to load it in my HTML file with this code:
<div class="form-group col-lg-12">
<table class="table">
<thead>
<tr>
<th>Fornavn</th>
<th>Efternavn</th>
<th>Køn</th>
<th>Fødselsdag</th>
<th>Læs mere</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="visit in donorerVisits">
<td>{{visit.firstname}}</td>
<td>{{visit.lastname}}</td>
<td>{{visit.sex}}</td>
<td>{{visit.age}}</td>
<td><button class="btn btn-default">Læs mere</button></td>
</tr>
</tbody>
</table>
</div>
In my Index html I load in these JS files:
<!-- JS -->
<script src="libs/angular.js" type="text/javascript"></script>
<script src="libs/angular-ui-router.min.js" type="text/javascript"></script>
<script src="libs/angular-resource.js" type="text/javascript"></script>
<!-- Angular Custom -->
<script type="text/javascript">
angular.module("testApp", ['ui.router']);
</script>
<script src="js/controllers/HjemCtrl.js"></script>
<script src="js/controllers/DonorerCtrl.js"></script>
<script src="js/controllers/BlodCtrl.js"></script>
<script src="js/navigation.js"></script>
Upvotes: 0
Views: 376