Skip to content

Instantly share code, notes, and snippets.

@Aldo-f
Last active October 15, 2019 14:31
Show Gist options
  • Save Aldo-f/ce9e7a455a20c95f82de72e9021a97f2 to your computer and use it in GitHub Desktop.
Save Aldo-f/ce9e7a455a20c95f82de72e9021a97f2 to your computer and use it in GitHub Desktop.
Get data from child
import Ember from 'ember';
export default Ember.Component.extend({
didReceiveAttrs() {
//debugger;
this._super(...arguments);
}
});
import Ember from 'ember';
export default Ember.Component.extend({
currentValue: false,
value: null,
init() {
this._super(...arguments);
this.set('value', 'Start value');
},
actions: {
addValue(data) {
console.log(data);
this.toggleProperty('currentValue');
this.set('value', data);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Get data from child'
});
<h1>{{appName}}</h1>
<MyParent/>
<form>
{{input value=data}}
<button {{action passDataToParent data}}>Add & toggle</button>
{{my-sub-child passDataToParent=(action "addValue")}}
</form>
Current Value: {{currentValue}}<br>
Input Value: {{value}}<br>
{{my-child passDataToParent=(action "addValue")}}
{{yield}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment