我知道这个问题有点多余,而且有很多资源,但我已经在这一天工作了一天以上,我只是看不出我做错了什么。
编辑* 我想知道我是否遇到了CORS功能的问题,所以我托管了一个子域并添加了对这个测试子域的支持......仍然没有数据出现......
http://test.spcomputerclub.com/news/
http://api.spcomputerclub.com/Help/Api/GET-Api-Forums
app.js
var myApp = angular.module('myApp', [
'myControllers',
'myServices'
]);
controller.js
var myControllers = angular.module('myControllers', []);
myControllers.controller('myControllers', ['$scope', 'ForumIndexItem', function ($scope, ForumIndexItem) {
$scope.data = {};
ForumIndexItem.query(function(response){
$scope.data.issues = response;
});
}]);
service.js
var myServices = angular.module('myServices', ['ngResource']);
myServices.factory('ForumIndexItem', function ($resource) {
return $resource('http://api.XXXXXXXX.com/Api/Forums', {})
})
HTML
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Practice</title>
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-resource.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body>
<ul>
<li ng-repeat="ForumIndexItem in data.issues">
<p>{{ForumIndexItem.ForumName}}</p>
</li>
</ul>
</body>
</html>