Sunday, 15 March 2015

ember.js - How to render an ember-data date in a template -



ember.js - How to render an ember-data date in a template -

i'm trying print date attr in handlebars template. output empty. how render it?

my model:

app.post = ds.model.extend({ type: ds.attr('string'), title: ds.attr('string'), summary: ds.attr('string'), body: ds.attr('string'), date: ds.attr('date') }); app.post.fixtures = [ {id:1, type:"news", title:"some", summary:"lorem ", date:new date()}, {id:2, type:"gallery", title:"some", summary:"lorem", date:new date()} ];

my handlebars template:

<script type="text/x-handlebars" data-template-name="posts"> {{#each post in controller}} {{post.date}}: {{post.type}}- {{post.title}} {{/each}} </script>

you cannot utilize new date() in fixture itself, should using isostring or similar. remember transform date looks string come persistence layer (in case fixture) , convert date object string.

so, set date in fixture "2013-02-07t16:44:57.000z" or similar i.e. "2013-02-07t16:44:57" should work too.

ember.js

No comments:

Post a Comment