Skip to content

Instantly share code, notes, and snippets.

@locks
Last active February 6, 2017 19:37
Show Gist options
  • Save locks/40fe22fd5553331c86fb to your computer and use it in GitHub Desktop.
Save locks/40fe22fd5553331c86fb to your computer and use it in GitHub Desktop.
attrs
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions:{
saveMessage(message) {
console.log("message", message);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{#my-component save=(action 'saveMessage') as |save|}}
{{my-component-yielded save=save}}
{{/my-component}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
});
<button {{action save "child"}}>Save the child</button>
<button onclick={{action save "native child"}}>Save the child [native element]</button>
import Ember from 'ember';
export default Ember.Component.extend({
});
<button {{action (action save "yielded")}}>Save the yielded</button>
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
alternativeSave() {
this.get('save')('alternative parent');
}
}
});
<button {{action (action save "parent")}}>Save the parent</button><button {{action 'alternativeSave'}}>Save alternative parent</button>
{{my-component-child save=save}}
{{yield (action save)}}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment