简体   繁体   中英

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. I'm using 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.

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

My HTML file is showing:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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