Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Last active December 20, 2015 23:18
Show Gist options
  • Save alexspeller/6210957 to your computer and use it in GitHub Desktop.
Save alexspeller/6210957 to your computer and use it in GitHub Desktop.
var utils = require('../utils.js');
var ChannelsModel = require('../models/channels.js');
var ChannelModel = require("../models/channel.js");
var ChannelsRoute = Ember.Route.extend({
model: function() {
return ChannelsModel.findAll().then(function(result){
return Ember.Object.create({
channels: result,
subChannels: function() {
var sbList = Ember.A();
this.channels.forEach(function(c) {
sbList.pushObject(ChannelModel.find(c.id));
});
return sbList;
}
});
})
},
setupController: function(controller, model) {
controller.set('channels', model.channels());
controller.set('subChannels', model.subChannels());
}
});
module.exports = ChannelsRoute;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment