How to call a route action from inside the component?
vasilakisfil opened this issue · 6 comments
can this helper help on this situation or is it out of the context ?
When passing a route's action using the route action helper to a component, you can call the the route action as if it was passed a normal action.
Does this answer your question?
hmm not sure. I love this component because I can call any route action without registering it first (injecting it to the component)
I want to do the same, but from the component class: let's say I have the following component that listens to componentAction
.
If I have this in the template:
with this compoennt class:
// application/route.js
import Ember from 'ember';
const { Route, set } = Ember;
export default Route.extend({
actions: {
componentAction(...args) {
this.sendAction('routeActionHere', ...args);
}
}
});
Is it possible to call the route action like this ?
@vasilakisfil Yes, you could replace componentAction
with the routeActionHere
in the template and then remove the componentAction
from your code.
Either:
Or:
interesting but what if you want to process something locally in the Component and then fire the action to the route ?
@vasilakisfil Then you could either use the pipe
helper from the ember-composable-helpers addon or resort back to your initial solution.
Ok from what I understand it's not possible what I am saying :) It would be nice to have it though. I think.
Keep up the good work! 👍