Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closure actions should be defined on controller

Ember 1.13.10

I wanted to try out the closure actions, so I defined the a route:

import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    doSave() { ... }
  }
});

and the template:

{{my-component onSave=(action 'doSave')}}

But I get the error message: An action named 'doSave' was not found in (generated test.index controller).

However it is defined on the route. Given the fact that Controllers are kind of deprecated in Ember I would expect that the action should be defined on the route instead of the controller. Is there a specific reason why the closure actions should be defined on the controller?

like image 705
Willem de Wit Avatar asked Mar 14 '23 02:03

Willem de Wit


1 Answers

Closure actions communicate with the controller not the route, once routable components land they will replace controllers.

In your case if you wish to bubble the action you will have to send it from the controller.

like image 108
Patsy Issa Avatar answered Mar 21 '23 04:03

Patsy Issa