Reputation: 1404
I am trying to sort by date the repos in GitHub using their JSON API.
I am using Ember 1.13.7
I have reproduced my case in jsbin, the problem is that i can not even see the console error to understand the problem
This is the code applied ( it is commented in the jsbin )
In my controller
sortProperties: ['created_at:asc'],
sortedRepos: Ember.computed.sort('model', 'sortProperties')
in My Template
{{#each model.repos in sortedRepos}}
<li>{{name}}</li>
<li>{{format-date "LL" created_at}}</li>
{{/each}}
What' s the error here? how can i sort this model by date ( the latest )?
P.s I am using an helper template {{format-date}} with moment js
Upvotes: 0
Views: 1231
Reputation: 3207
here is working jsbin
you were sorting wrong property it should be model.repos
not model
and in jsbin you were creating sorted computed property in ApplicationController
not IndexController
by the way you are using old iteration style/syntax once you upgrade your ember to 2.x.x
you should be using
{{#each sortedRepos as |repo|}}
<li>{{repo.name}}</li>
<li>{{format-date "LL" repo.created_at}}</li>
{{/each}}
Upvotes: 2