Skip to content

Instantly share code, notes, and snippets.

@jackkitley
Created January 24, 2013 09:18
Show Gist options
  • Save jackkitley/4619021 to your computer and use it in GitHub Desktop.
Save jackkitley/4619021 to your computer and use it in GitHub Desktop.
New ember js pre 4 problem
App.DashboardController = Em.ArrayController.extend({
content: [],
contentRecent: Em.ArrayController.create({
content: [],
count: Em.computed(function() {
return this.get('content').length;
}).property('content.@each')
}),
@zeppelin
Copy link

App.DashboardController = Em.ArrayController.extend({
  content: []
});

App.RecentItemsController = Em.ArrayController.extend({
  content: [],
  count: Em.computed(function() {
    return this.get('content').length;
  }).property('content.@each')
});

// In your route:

App.DashboardRoute = Em.Route.extend({
  setupController: function(controller, model) {
    // The `controller` argument is the controller matching the route's name,
    // in this case the `DashboardController`'s instance
    this.controller.set('content', ["a", "b", "c"]);
    this.controllerFor('recentItems').set('content', ["d", "e", "f"]);
  }
});

// For more examples see: http://emberjs.com/guides/routing/setting-up-a-controller/

@zeppelin
Copy link

Fuck, forgot the -Controller from the RecentItems. Of course, it's RecentItemsController...
Updated the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment