Skip to content

Instantly share code, notes, and snippets.

@emurillo510
Created October 26, 2016 06:00
Show Gist options
  • Save emurillo510/77b8f61390b6324fdbfd0f03a13a28ba to your computer and use it in GitHub Desktop.
Save emurillo510/77b8f61390b6324fdbfd0f03a13a28ba to your computer and use it in GitHub Desktop.
Passing Data
import Ember from 'ember';
export default Ember.Component.extend({
firstName:"Elton",
actions: {
getData(fromChild){
alert('i got it' + fromChild);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
getInput(){
let data = this.get('data');
this.sendAction('action', data);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
{{parent-component}}
<h1>Parent Component</h1>
{{sub-component data=firstName action="getData"}}
<h1>Subcomponent</h1>
{{input value=data}}
<button {{action 'getInput'}}>Get User Input</button>
{
"version": "0.10.6",
"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.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment