How to specify a component action target to a route?

Suppose I have a component called ‘play-music’, and it has a action called ‘play’, what could I do to specify the action target to a route, but not the controller.
I tried play=(action 'play' target="route:someRouteName"), but I had a error said can not find action of undefined.
please help me .

In your case, you’ll want to go the sendAction route instead of passing the action around as a closure, which in that case is the target. Using sendAction will allow the action the bubble in the way you’re expecting. component → controller → route

1 Like

I just ran into this problem a moment ago- except I was trying to invoke the action on the route of the template the component was used in- by doing the following:

{{my-component onSave='handleSave`}}

actions: {
  handleSave() { ... }

this.sendAction( 'onSave' );

I’m unsure why when passing the action as a closure it bubbles up to the controller and not the route. Perhaps once they do away with controllers and have routable components it would simply then bubble up to the route?

Is there a solution to closure actions from a route assigned to a component?

1 Like