Nairam
Nairam

Reputation: 285

Ember get sorted content in another controller

I have an Ember.ArrayController that gets it's model from the route and applies some sorting.
Example:

App.IndexRoute = Ember.Route.extend({
model: function() {
    return [Ember.Object.create({id: 23, name: "John"}),
            Ember.Object.create({id: 534, name: "Warren"}),
            Ember.Object.create({id: 234, name: "Katy" })
     ];
  }
});

App.IndexController = Ember.ArrayController.extend({
    sortProperties: ["id"],
    sortAscending: true

});

When I call the correspondant template and loop through the IndexController the sorted content is shown as expected.
However if I retrieve the content of this controller in another controller with this.get("controllers.index.content"); and show it in it's template the sorting is not applied. Why is that? I thought that this.get("controllers.index.content"); would retrieve the same content that the orignal controller is retrieving, therefore, the sorted content. How could I retrieve the same sorted content on the other controller aswell?
Here is an example jsfiddle
Thanks!

Upvotes: 0

Views: 464

Answers (1)

buuda
buuda

Reputation: 1427

Use the arrangedContent property, instead of content, for the sorted content:

this.get("controllers.index.arrangedContent");

Upvotes: 1

Related Questions