Skip to content

Instantly share code, notes, and snippets.

@stevekane
Last active December 18, 2015 13:19
Show Gist options
  • Save stevekane/5789403 to your computer and use it in GitHub Desktop.
Save stevekane/5789403 to your computer and use it in GitHub Desktop.
Dashboard setup for Ember cats and dogs
<script type="text/x-handlebars">
<h1>Dashboard</h1>
{{outlet cats}}
{{outlet dogs}}
</script>
<script type="text/x-handlebars" data-template-name="cats">
{{#each cat in controller.content}}
{{cat}}
{{/each}}
</script>
<script type="text/x-handlebars" data-template-name="dogs">
{{#each dog in controller.content}}
{{dog}}
{{/each}}
</script>
App.router.map(function () {
this.resource('cats');
this.resource('dogs');
this.resource('dashboard');
});
App.DashboardRoute = Ember.Route.extend({
//Ember gives us access to the instance of DashboardController
//we define our it will autogenerate one by that name for you
setupControllers: function (controller) {
controller.get('controllers.cats').set('content', App.Cat.find());
controller.get('controllers.dogs').set('content', App.Dog.find());
},
renderTemplates: function (controller) {
this.render('cats', {
into: 'application',
outlet: 'cats',
controller: 'cats'
});
this.render('dogs', {
into: 'application',
outlet: 'dogs',
controller: 'dogs'
});
},
});
App.DashboardController = Ember.Controller.extend({
needs: ['cats', 'dogs'],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment