我变得非常沮丧,我知道这一定是我犯的一个简单的错误。所以,我正在尝试从Behance上的帐户中获取一些图像,并将它们显示在我自己的网站上。我正在使用AngularJS。使用以下代码,我能够得到回复:
'use strict';
angular.module('angularApp')
.controller('BehanceCtrl', function ($scope, $resource) {
$scope.behance = $resource('http://www.behance.net/v2/users/zachjanice/projects?client_id=xxxxxxxxxx',
{ q:'', callback: 'JSON_CALLBACK'},
{get:{method:'JSONP'}}
);
$scope.behanceResult = $scope.behance.get();
});
在Chrome开发者工具中显示我收到了回复。
angular.callbacks._0({"projects":[{"id":123456, etc. etc.}] })
我的HTML文件显示:
<section ng-controller="BehanceCtrl">
<div class="container">
<div class="row">
<ul>
<li ng-repeat="behance in behanceResult.results">
<img ng-src="{{projects.covers}}">
<h1>{{projects.id.name}}</h1>
</li>
</ul>
</div>
</div>
</section>
我要离开的是什么?如何显示这些图像的图像和标题。
感谢任何帮助。
答案 0 :(得分:1)
<section ng-controller="BehanceCtrl">
<div class="container">
<div class="row">
<ul>
<li ng-repeat="behance in behanceResult.results">
<img ng-src="{{behance.projects.covers}}">
<h1>{{behance.projects.id.name}}</h1>
</li>
</ul>
</div>
</div>
答案 1 :(得分:0)
您应该使用的数组是behanceResult.projects
,因此这应该有效:
<div class="container">
<div class="row">
<ul>
<li ng-repeat="project in behanceResult.projects">
<img ng-src="{{project.covers[202]}}">
<h1>{{project.name}}</h1>
</li>
</ul>
</div>