Skip to content

Instantly share code, notes, and snippets.

@morhook
Created January 12, 2017 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morhook/9967cadc77386737f590d0c869e9a47b to your computer and use it in GitHub Desktop.
Save morhook/9967cadc77386737f590d0c869e9a47b to your computer and use it in GitHub Desktop.
detecting if action is passed in
import Ember from 'ember';
export default Ember.Component.extend({
onGo: Ember.K,
passed: Ember.computed(function() {
return this.get('onGo') !== Ember.K;
}),
click() {
console.log('clicked on my-compoent, now calling action passed');
this.get('onGo')();
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
go() {
console.log('gooo');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-component}}
{{my-component onGo=(action 'go')}}
<br>
<br>
{{yield}}
inside component
{{passed}}
{
"version": "0.10.7",
"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.10.0",
"ember-data": "2.10.0",
"ember-template-compiler": "2.10.0",
"ember-testing": "2.10.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment