Last active
September 21, 2015 19:13
-
-
Save ErikCH/26b48e5c605e7d0a7b6f to your computer and use it in GitHub Desktop.
New Twiddle
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'; | |
var Light = Ember.Object.extend({ | |
isOn: false, | |
color: 'yellow', | |
age: null, | |
description: Ember.computed('isOn','color',function() { | |
return 'The ' + this.get('color') + ' light is ' + (this.get('isOn') ? 'on' : 'off'); | |
}), | |
// fullDescription: Ember.computed('description','age',function() { | |
// return this.get('description') + ' and the age is ' + //this.get('age') | |
// }), | |
// desc: Ember.computed.alias('description'), | |
// isOnChanged: Ember.observer('isOn','color',function() { | |
// }) | |
}); | |
Light.reopen({ | |
checkIsOn: Ember.observer('isOn','color', function() { | |
Ember.run.once(this,'checkChanged'); | |
}), | |
checkChanged: Ember.observer('description',function() { | |
console.log(this.get('description')); | |
}) | |
}); | |
var bulb1 = Light.create({age: 22}); | |
bulb1.set('isOn', true); | |
bulb1.set('color', 'blue'); | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
bulb: Light.create({age: 19}), | |
actions:{ | |
buttonPressed: function() { | |
this.get('bulb').toggleProperty('isOn'); | |
this.get('bulb').set('color','red'); | |
} | |
} | |
}); |
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.4.10", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment