Skip to content

Instantly share code, notes, and snippets.

@siva-sundar
Last active December 22, 2015 09:37
Show Gist options
  • Save siva-sundar/18f1e3d2a2aae62e95d5 to your computer and use it in GitHub Desktop.
Save siva-sundar/18f1e3d2a2aae62e95d5 to your computer and use it in GitHub Desktop.
actions will be available in this.controller.actions
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
apple() {
alert('action is available');
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
checkActionAvailable: function(actionName) {
if(Em.get(this.controller.actions,actionName)) {
this.get('controller').send(actionName);
}
}
}
});
<h2> actions will be available in this.controller.actions </h2>
<br>
<br>
<button {{action 'checkActionAvailable' 'apple'}}> click here</button>
{{outlet}}
<br>
<br>
{
"version": "0.4.17",
"EmberENV": {
"FEATURES": {}
},
"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