Created
August 15, 2019 21:05
-
-
Save WenInCode/27ccf6d8830f4179024d19d039fdf02f to your computer and use it in GitHub Desktop.
computed prop key example
This file contains 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({ | |
appName: 'Ember Twiddle', | |
data: { cluster: { type: 'pg' }}, | |
computedTopLevel: Ember.computed('data', function() { | |
return this.get('data.cluster.type') === 'pg' ? 'POSTGRES' : 'MYSQL'; | |
}), | |
computedActualProp: Ember.computed('data.cluster.type', function() { | |
return this.get('data.cluster.type') === 'pg' ? 'POSTGRES' : 'MYSQL'; | |
}), | |
actions: { | |
toggleType() { | |
if (this.get('data.cluster.type') === 'pg') { | |
this.set('data.cluster.type', 'mysql'); | |
} else { | |
this.set('data.cluster.type', 'pg'); | |
} | |
} | |
} | |
}); |
This file contains 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