Skip to content

Instantly share code, notes, and snippets.

@leondmello
Created September 18, 2019 20:10
Show Gist options
  • Save leondmello/81f804dfefe9eac348e05627bc432d63 to your computer and use it in GitHub Desktop.
Save leondmello/81f804dfefe9eac348e05627bc432d63 to your computer and use it in GitHub Desktop.
Cp Dep
import Ember from 'ember';
import { computed } from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
color: 'none',
isGreen: computed('', function() {
return this.get('color') === 'green';
}),
isGreenCorrect: computed('color', function() {
return this.get('color') === 'green';
}),
actions: {
selected(color) {
this.set('color', color)
}
}
});
<div style="padding:5px">
<button {{action 'selected' 'green'}} style="padding:5px"> green</button>
<button {{action 'selected' 'yellow'}} style="padding:5px"> yellow</button>
</div>
<div style="padding:5px">IsGreen checked: {{isGreen}} (Without CP Dep)</div>
<div style="padding:5px">IsGreen checked: {{isGreenCorrect}} (With CP Dep) </div>
<div style="padding:5px">Color: {{color}}</div>
{
"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