2

Ember version 2.2

So I have these two routes defined /Build /Build/education

Inside of the education route I have a component, and I'm trying to pass an action to it.

Education.hbs

  {{#each model as |school|}}
        {{common-education-institution model=school  onAddSubject=(action 'addSubject')}}
    {{/each}}     

And I have an action defined in education.js

import Ember from 'ember';

export default Ember.Route.extend({
model() {
    return this.modelFor('build').get('education');
}, 
actions: {
    addSubject() {

    }
}
});

When I start the app I get this error:

Uncaught Error: An action named 'addSubject' was not found in (generated build.education controller).

Education is a route not a controller, why is this error coming up??

Also I would like to define the action in build.js rather than education.js but the above is a greater problem. Any ideas on how to fix this?

Marcom
  • 4,621
  • 8
  • 54
  • 78
  • Closure actions communicate with the controller and not the route. – Patsy Issa Nov 23 '15 at 15:14
  • is there a way to make it work with a route? I've been trying to get the app working with routes and components – Marcom Nov 23 '15 at 15:16
  • 2
    Yes you ll have to use regular actions and send them from the component. – Patsy Issa Nov 23 '15 at 15:17
  • 1
    Possible duplicate of [Closure actions should be defined on controller](http://stackoverflow.com/questions/33866969/closure-actions-should-be-defined-on-controller) – Patsy Issa Nov 23 '15 at 15:18
  • 1
    Check this answer may help you http://stackoverflow.com/questions/31101296/how-to-call-an-action-on-a-route-using-closure-actions – Jose CC Nov 23 '15 at 16:02

0 Answers0