2013-09-24 3 views
0

데이터를 올바르게 표시하려면 도움이 필요합니다. 내가이 오류를 제거하고 올바르게 이미지 (들)을 표시합니까 어떻게ember.js에서 객체/값과 같은 배열에 액세스하는 방법

Assertion failed: Attributes must be numbers, strings or booleans, not [http://example.com/imgage/example_thumb.jpg]

: 내가 썸네일 경로에 액세스하려고하면 응용 프로그램은 다음과 같은 오류가 발생합니다?

DEBUG: ------------------------------- 
DEBUG: Ember.VERSION : 1.0.0 
DEBUG: Handlebars.VERSION : 1.0.0 
DEBUG: jQuery.VERSION : 2.0.3 
DEBUG: ------------------------------- 

// models/collection_model.js 
App.Collection = DS.Model.extend({ 
    title: DS.attr('string'), 
    assets: DS.attr('object') 
}); 


// datastore.js 
App.Collection.FIXTURES = [ 
    { 
     "id": 1, 
     "title": "Lorem ipsum", 
     "assets": { 
      "thumb": ['http://example.com/imgage/example_thumb.jpg'], 
      "thumb_large": ['http://example.com/imgage/example.jpg'] 
     } 
    }, 
    { 
     "id": 2, 
     "title": "Losabim", 
     "assets": { 
      "thumb": ['http://example.com/imgage/example_thumb.jpg'], 
      "thumb_large": ['http://example.com/imgage/example.jpg'] 
     } 
    } 
]; 

// templates/collection.handlebar 
<script type="text/x-handlebars" data-template-name="collections"> 
    <h2>Collections</h2> 
    <ul> 
     {{#each collection in controller}} 
      <li> 
       {{collection.title}} 
       <img {{bind-attr src=collection.assets.thumb }}/> 
      </li> 
     {{/each}} 
    </ul> 
</script> 
+0

더 – gearsdigital

답변

1

엠버는 firstObjectlastObject가 없습니다 : 도대체 API가 배열을 반환하는 이유

<img {{bind-attr src=collection.assets.thumb.firstObject }}/> 
+0

당신 alexspeller 감사 ... 물어 마십시오! 기록 : http://emberjs.com/api/classes/Ember.ArrayProxy.html#property_firstObject – gearsdigital

관련 문제