Skip to content

Instantly share code, notes, and snippets.

@sukima
Forked from velrest/components.my-componenta.js
Created August 27, 2018 14:03
Show Gist options
  • Save sukima/84d79ba4c4891338884bfd9c1b8aec0b to your computer and use it in GitHub Desktop.
Save sukima/84d79ba4c4891338884bfd9c1b8aec0b to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
open(){
//do stuff
let image = 'yay image'
this.get('childManager').select(image)
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
init(){
this._super(...arguments);
this.get('registerComponentManager')({
select: (image) => this.send('select', image)
})
},
actions: {
select(image){
this.set('image', image)
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#my-componenta as |child|}}
{{#child as |select|}}
{{/child}}
{{/my-componenta}}
<br>
<br>
{{yield (component "my-componentb"
registerComponentManager=(action (mut childManager))
)}}
{{yield (action 'select')}}
{{#if image}}
{{image}}
{{else}}
no image
{{/if}}
{
"version": "0.15.0",
"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.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment