O'Reilly logo

Ember.js Cookbook by Erik Hanchett

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

Managing dependencies between controllers

Often, controllers will need to access other controllers' properties and models. This is especially important when you have nested resources. In this recipe, we'll take a look at a nested controller that needs access to the parent controller's model and properties.

How to do it...

  1. In a new application, generate a couple of new routes and templates:
    $ ember g route foo1
    $ ember g route foo1/foo2
    $ ember g controller foo1
    $ ember g controller foo1/foo2
    $ ember g template index
    

    This generates the foo1 and foo2 routes and controllers. The foo2 route is a nested route. The index template will contain links.

  2. Verify in the router.js file that all the routes have been created correctly:
    // app/router.js import Ember ...

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