BGA
BGA

Reputation: 27

emberjs arraycontroller not sorting

I have reviewed many examples but I can't seem to make my ArrayController sort! I have: (fiddle http://jsfiddle.net/6bphs4h7/1/)

<script type="text/x-handlebars" data-template-name="usergroups">
<ul>
  {{#each}}
    <li>{{name}}
  {{/each}}
</ul>
</script>

var App = Ember.Application.create({});

App.UsergroupsRoute = Ember.Route.extend({
  model: function(params) {
    return [ 
        Ember.Object.create({id: 1, name: 'foo'}), 
        Ember.Object.create({id: 2, name: 'bar'}) 
    ];
  }
});

App.UsergroupsGroupsController = Ember.ArrayController.extend({
  sortProperties: ['name'],
  sortAscending: true,
});

App.Router.map(function(){
  this.resource('usergroups', {path: '/'});
});

Upvotes: 1

Views: 156

Answers (1)

TheDude
TheDude

Reputation: 3952

Is it because your controller is different than the route with the model?

App.UsergroupsController = Ember.ArrayController.extend({
  sortProperties: ['name'],
  sortAscending: true,
});

Your controller was for UsergroupsGroups when it should be Usergroups.

Upvotes: 2

Related Questions