vendredi 15 janvier 2016

Binding component actions to route and getting the returned result

Say I have the following component

{{my-component onSaved=(action 'save')}}

I want to define the "save" action on the route not the controller.

actions: {
  save(model): {
    return model.save();
  }
}

The returned promise is important as I need it in the component code.

const pendingPromise = this.attrs.onSave(model);

This does not work and says it can't find the action. Is this possible somehow? Even if I provide an action in the controller to simply call the one in the route there is still no way to get hold of the returned promise.

actions: {
  saveIntermediary(model) {
    this.send('save', model); // can't get hold of the response!!!!
  }
}

{{my-component onSaved=(action 'saveIntermediary')}}




Aucun commentaire:

Enregistrer un commentaire