1

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: '/'});
});

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

here is a bin showing it working correctly once changed to UsergroupsController. See: emberjs.jsbin.com/moxape/1/edit
sigh... I have spent days looking at this piece of code. Thanks. I need a smarter ide (or coder). Thanks.
@user3746371 You need the Ember debugger plugin for Chrome. This shows your view hierarchy and which controllers and models are being used for each.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.