简体   繁体   English

使用AngularJS从Behance Api发布图像

[英]Posting an image from Behance Api with AngularJS

I'm getting really frustrated and I know it must be a simple mistake I'm making. 我真的很沮丧,我知道这一定是我犯的一个简单错误。 So, I'm trying to get some images from my account on Behance and display them on my own site. 因此,我试图从我在Behance上的帐户中获取一些图片,并将其显示在我自己的网站上。 I'm using AngularJS. 我正在使用AngularJS。 With the following code I'm able to get a response: 使用以下代码,我可以获得响应:

'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();

  });

In Chrome developer tools shows I'm getting a response. 在Chrome开发人员工具中显示我得到了回应。

angular.callbacks._0({"projects":[{"id":123456, etc. etc.}] })

My HTML file is showing: 我的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>

What am I leaving out? 我遗漏了什么? And how can I display the images and headings for those images. 以及如何显示图像和这些图像的标题。

Any help is appreciated. 任何帮助表示赞赏。

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

The array you should use is behanceResult.projects , so this should work: 您应该使用的数组是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