Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Grokking Contextual Components
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
items: [1, 2, 3]
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#my-wrap name="Kyle" as |f|}}
{{#each items as |item|}}
{{f.foo name=item age=item}}
{{/each}}
{{#f.foo as |g|}}
{{g.babyFoo}}
{{g.babyBar}}
{{/f.foo}}
{{f.bar name="Homey"}}
{{#f.foo as |h|}}
{{h.babyBar}}
{{h.babyFoo}}
{{/f.foo}}
{{f.foo age='31'}}
{{f.bar}}
{{f.babyBar}}
{{/my-wrap}}
<h4>Foo - {{name}}, {{age}}</h4>
{{yield
(hash
babyFoo=(component 'baby-foo')
babyBar=(component 'baby-bar')
)
}}
<h3>Wrap Component</h3>
{{yield
(hash
foo=(component 'my-foo' name=name)
bar=(component 'my-bar' name=name)
)
}}
{
"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