Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Created August 24, 2016 10:13
Show Gist options
  • Select an option

  • Save LevelbossMike/7ccebb23d85c79b4afdd4227f8029c8b to your computer and use it in GitHub Desktop.

Select an option

Save LevelbossMike/7ccebb23d85c79b4afdd4227f8029c8b to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.get('register')(this);
},
willDestroyElement() {
this._super(...arguments);
this.get('unregister')(this);
}
});
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Component.extend({
children: computed(function() {
return [];
}),
childCount: computed('children.[]', function() {
return this.get('children.length');
}),
actions: {
registerChild(child) {
this.get('children').pushObject(child);
},
unregisterChild(child) {
this.get('children').removeObject(child);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{#x-wizard as |wizard|}}
{{#wizard.step}}
step1
{{/wizard.step}}
{{#wizard.step}}
step 2
{{/wizard.step}}
{{/x-wizard}}
<br>
<br>
<h2>Wizard-step</h2>
{{yield}}
Child-count: {{childCount}}
{{yield (hash
step=(component 'x-wizard-step' register=(action 'registerChild') unregister=(action 'unregisterChild'))
)}}
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment