javascript - How to access array like object/values in ember.js -
i need display data correctly. if try access thumbnail path, application throws following error:
assertion failed: attributes must numbers, strings or booleans, not [http://example.com/imgage/example_thumb.jpg]
how rid of error , show image(s) correctly?
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>
ember has firstobject
, lastobject
:
<img {{bind-attr src=collection.assets.thumb.firstobject }}/>
Comments
Post a Comment