Skip to content

Instantly share code, notes, and snippets.

@adam-knights
Forked from siva-sundar/application.controller.js
Last active December 22, 2015 09:51
Show Gist options
  • Save adam-knights/47f8b30c09d2607b2c64 to your computer and use it in GitHub Desktop.
Save adam-knights/47f8b30c09d2607b2c64 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'
});
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
apple() {
alert('action is available');
},
checkActionAvailable: function(actionName) {
console.log(this);
if(Em.get(this.actions,actionName)) {
this.send(actionName);
}
}
}
});
<h2> Why are actions not available in this.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