繁体   English   中英

使用AngularJS从Behance Api发布图像

[英]Posting an image from Behance Api with AngularJS

我真的很沮丧,我知道这一定是我犯的一个简单错误。 因此,我试图从我在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>

我遗漏了什么? 以及如何显示图像和这些图像的标题。

任何帮助表示赞赏。

<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>

您应该使用的数组是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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM