Skip to content Skip to sidebar Skip to footer

Accessing Ember-cli Nested Controllers

This is my directory structure: controllers/ ---- restaurant/ ----items.js ---- index.js ---- restaurant.js And my router declaration: this.route('restaurants',{ path: '/resta

Solution 1:

As of Ember-CLI v0.2.1 + Ember v1.10.0 (could work for earlier versions; but I haven't tried), this is how you do it:

exportdefault Ember.ObjectController.extend({
    needs: ["restaurant/items"],
    ...

To access actions, you'd do this:

actions: {
    myAction: function(arg1, arg2) {
      this.get('controllers.restaurant/item').send('someItemActionYouDefine', arg1, arg2);
    }
}

Solution 2:

I don't think you're Items controller needs to be in the subfolder restaurant. Move it up a level and see if that fixes the issue.

Post a Comment for "Accessing Ember-cli Nested Controllers"