Last active
August 8, 2019 21:53
-
-
Save lukecoy/301155e3e0230ae22c8c65aa883ccecb to your computer and use it in GitHub Desktop.
controller bind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
actions: { | |
actionThatShouldNotBeOverriden() { | |
console.log('yay'); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return { foo: 'bar' }; | |
}, | |
actionOne() { | |
this.set('controller.model.foo', 'Mutation 1!'); | |
}, | |
actionTwo() { | |
this.set('controller.model.foo', 'Mutation 2!'); | |
}, | |
setupController(controller) { | |
this._super(...arguments); | |
if (!controller.get('actions')) controller.set('actions', {}); | |
controller.setProperties({ | |
'actions.actionOne': this.get('actionOne').bind(this), | |
'actions.actionTwo': this.get('actionTwo').bind(this) | |
}); | |
if (controller.get('actions.actionThatShouldNotBeOverriden')) { | |
this.set('controller.model.baz', 'The native controller action is still defined :)') | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment