2

I have a set of nested resources set up in my application. I need to use a beforeModel and afterModel hook for some of my routes. However, when attempting to call a function or get a property of another controller I get an error stating that the controller named {name} cannot be found. This happens when I am attempting to use this.controllerFor('name') inside my nested route. Is there a workaround for this?

csm232s
  • 1,660
  • 4
  • 32
  • 60
  • `controllerFor` has been deprecated. You should use `needs: []`. Here is a recent answer I wrote pertaining to this: http://stackoverflow.com/a/25175102/1710611 – rog Oct 29 '14 at 05:49

1 Answers1

2

In order to use controllerFor the controller must be defined. If your controller is dynamically generated asking Ember to give you it won't work. Controllers aren't generated until after all models are resolved (including before and after model hooks) during the setupController phase.

Kingpin2k
  • 47,277
  • 10
  • 78
  • 96
  • Looking at my code there is some refactoring I shold do to remove the need for controllerFor. Thanks for the clarification! – csm232s Oct 28 '14 at 21:01