O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying controller dependencies

Controller dependencies enable controllers to associate. Therefore, whenever a controller needs to access the properties of another controller, it should first declare the controller as a dependency in order for it to be able to do so. These dependencies are defined in the needs property of the affected controller. For example, let's say we decided to add a commenting system to our blog application:

  this.resource('post', {path: '/post/:post_id'}, function(){
    this.resource('comments', function(){
  });    });

In a typical blog, comments are usually displayed on a separate page, and in our case, at a page with a path such as /post/100/comments. We will need to define a comments template that lists the loaded comments ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required