Closure actions should be defined on controller

让人想犯罪 __ 提交于 2019-12-10 09:26:53

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/33866969/closure-actions-should-be-defined-on-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!