I'm a little confused with the controller asigned to a route.
I want to create an action called "showModal" on the route but when I use this code ember sends an error that the action is not defined on the route:
export default Ember.Route.extend({
actions: {
showModal: function (params) {
console.info(params);
if (params) {
Custombox.open({
target: '.mModal',
closer: false
});
} else {
Custombox.close();
}
}
}
});
However, if I use the next code all seems to work fine, the modal action can be called by any component:
export default Ember.Route.extend({
setupController: function (controller, model) {
this._super(...arguments);
controller.set('actions', this.actions);
},
actions: {
showModal: function (params) {
console.info(params);
if (params) {
Custombox.open({
target: '.mModal',
closer: false
});
} else {
Custombox.close();
}
}
}
});
I would like to know, how can I assign a controller to a route? so the actions will be correctly defined on the route.
By the way I use the next ember-cli command to create my route: ember g route new/quote
Aucun commentaire:
Enregistrer un commentaire