Route transition with model from component


Hi, I want to redirect to a route “recipe/2” for example from a component.

In order to do this I injected the router
router: Ember.inject.service("-routing")

in my component and then I’ve tried to redirect on click using this

this.get("router").transitionTo("/recipe/" +; (Assertion Failed: The route /recipe/2 was not found)

I also tried using this.get("router").transitionTo("/recipe/",; (ember.debug.js:49883 Uncaught TypeError: objects.pop is not a function(…))

and this.get("router").transitionTo("/recipe/" , this.get("store").findRecord("recipe",; (ember.debug.js:49747 Uncaught TypeError: this.contexts.slice is not a function)

How should I do a redirect from component and why is not documented this very usual case? I mean, you have a component that searches for recipes for example and when the user hit click on one from search results you want to get him to that recipe. Is a usual case not some exception.



I suppose on injecting the Router to your component you should call transitionTo() method, transitionToRoute() is used with controllers injection, This may help Ember transitionToRoute cleanly in a component without sendAction


Hi, Sorry, I corrected the thread. I used transitionTo; that is the issue. it is not working with transitionTo. I mean, this works:


but this not:

transitionTo("recipe", recipeid)


transitionTo("recipe", recipeModel)


Hi there,

I assume your router is setup correctly with the following?

this.route('recipe', { path: '/recipe/:recipe_id });

or as a nested route.

this.route('recipes', function () {
  this.route('recipe', { path: '/:recipe_id });


I think that approach would not be very efficien. As components are suppose to work independently. Rather when an event happens and you want to transition to another route, use sendAction in the component with needed arrguments and let route handle the transition. You can also use closure action instead of sendAction.


Hi guys, Thanks for your replies; it seems that sending action in old way worked from now.