我正在尝试加载我的角度应用程序的“捐赠者”列表。我从API获取数据,但是我没有按照我想要的方式工作。我收到这个错误:
$ resourceProvider< - $ resource< - DonorerCtrl
在我的DonorerCtrl类中,我有以下代码:
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 = [];
});
我尝试使用以下代码将其加载到我的HTML文件中:
<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>
在我的索引html中,我加载了这些JS文件:
<!-- 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>
答案 0 :(得分:1)
尝试:
angular.module("testApp", ['ui.router', 'ngResource']);