dimanche 4 janvier 2015

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: "/restaurants"
});

this.resource("restaurant", {
path: "/restaurants/:restaurant_id"
}, function() {
this.resource("items", {
path: "/items"
});
});


My Items controller (located in restaurants/items.js) begins with the following:



export default Ember.ObjectController.extend({
needs: ["restaurant"],
restaurant: Ember.computed.alias('controllers.restaurant.model')


and is then followed by an action to add the item under hte restaurant.


However, I keep getting hte error saying "restaurant" needs to be added to "needs":



ReferenceError: (generated items controller)#needs does not include restaurant. To access the restaurant controller from (generated items controller), (generated items controller) should have a needs property that is an array of the controllers it has access to



This is my setup (Ember-CLI 0.1.2 with Ember 1.7) - As i'm using the fireplace adapter to work with firebase, I don't think it supports upgrading Ember (from what I've tried).



DEBUG: -------------------------------
DEBUG: Ember : 1.7.0"
DEBUG: Ember Data : 1.0.0-beta.10"
DEBUG: Handlebars : 1.3.0"
DEBUG: jQuery : 1.11.2"
DEBUG: Fireplace : 0.2.9"
DEBUG: -------------------------------


I've tried the other stackoverflow answers (e.g. How to communicate between controllers in Ember.js) but they don't seem to help.


Does anyone know what's going on here? Thanks!





Aucun commentaire:

Enregistrer un commentaire