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