Skip to content

Instantly share code, notes, and snippets.

@3gwebtrain
Forked from kumkanillam/components.my-child.js
Last active August 7, 2017 09:58
Show Gist options
  • Save 3gwebtrain/e782afbd49a23fdab4e77e324d3cdf5a to your computer and use it in GitHub Desktop.
Save 3gwebtrain/e782afbd49a23fdab4e77e324d3cdf5a to your computer and use it in GitHub Desktop.
Calling parent action from child
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
actions:{
show(){
console.log('show in parent');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions:{
callMe:function(){
alert("call me triggered");
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
{{my-parent funcCallme=(action 'callMe') }}
<br>
{{outlet}}
<br>
<br>
<button {{action show1}}> Parent </button>
{{yield}}
{{my-child show1=(action 'show')}}
<button {{action 'funcCallme' }}>Click me to get Alert</button>
{{yield}}
<button {{action show}}> Sub-child </button>
{{yield}}
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment