gokatz
9/29/2016 - 9:33 AM

Component Actions

Component Actions

{
  "version": "0.10.5",
  "EmberENV": {
    "FEATURES": {}
  },
  "options": {
    "use_pods": false,
    "enable-testing": false
  },
  "dependencies": {
    "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
    "ember": "2.8.0",
    "ember-data": "2.8.0",
    "ember-template-compiler": "2.8.0",
    "ember-testing": "2.8.0"
  },
  "addons": {}
}
<div style="background: red;">
<h3 {{action 'parentAction'}}>Parent</h3>
{{comp-child parentAction=(action 'parentAction')}}
<br>
</div>
<div style="background: yellow;">

<h3 {{action 'childAction'}}>Child</h3>

</div>
<h1>Welcome to {{appName}}</h1>
<br>
{{comp-parent}}
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';

export default Ember.Controller.extend({
  appName: 'Ember Twiddle'
});
import Ember from 'ember';

export default Ember.Component.extend({
  actions: {
    parentAction() {
      alert('parent');
    }
  } 
 });
import Ember from 'ember';

export default Ember.Component.extend({
  actions: {
    childAction() {
      alert('child');
      this.sendAction('parentAction');
    }
  } 
});