我正在用 Angular JS 和 StamPlay 创建一个小喊话框。因此,我创建了一些可以通过URL访问的“测试呐喊”
在我的 Angular 应用程序中,我创建了一个服务来获取数据:
app.factory('shouts', ['$http', function ($http) {
return $http.get('https://shoutbox.stamplayapp.com/api/cobject/v1/shouts').success(function (data) {
return data.data;
});
}]);
在我的 MainController 中,我将数据附加到 $scope。
app.controller('HomeController', [
'$scope',
'shouts',
function ($scope, shouts) {
$scope.shouts = shouts;
}
]);
但是,当我想通过数据 [] 重复 ng-repeat 时,我无法访问里面的对象。我不明白有什么问题。
<div ng-repeat="shout in shouts">
{{shout.title}}
</div>