Newbie, how to pass the data from the actions to the model?


#1

I have a component which sends action to the parent in the parent I have handled that action but I need to pass the data to the model hook so that to be rendered via template, pls help.


#2

In your action hook you would simply update the data in your model, the update to the model would be reflected in the template due to data binding.

Here is a simple action added to app/templetes/index.hsb It ends up calling the action “sayIT” which bubbles up from the template to the route:

<p><button {{action "sayIt" "BooYa!"}}>OK</button> </p>

The action above pass a string “BooYa!”, but it could also be a variable.

The action is handled in the route: app/routes/index.js

export default Ember.Route.extend({
   actions: {
      sayIt(s) {
         alert(s);
      }
   }
});

Hope this gives you an idea!