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'; | |
import { computed, get } from '@ember/object'; | |
export default Ember.Component.extend({ | |
baz: computed('foo', { | |
get() { | |
alert(get(this, 'foo')); | |
} | |
}) | |
}); |
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.Component.extend({ | |
// This is not working. | |
value: Ember.computed('object.{propertyName}', function() { | |
get() { | |
let prop = Ember.get(this, 'propertyName'); | |
return Ember.get(this, `object.${prop}`); | |
} |
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' | |
}); |
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', | |
a: Ember.computed('b', 'c', { | |
get() { | |
if (this.get('amountOfCalcs') === undefined) { | |
this.set('amountOfCalcs', 0); | |
} | |
else { |
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: 'Closures are awesome!', | |
actions: { | |
showAppNameWithClosure() { | |
alert('This failed because "this" is undefined in the scope of the closure function!'); | |
var test = function() { | |
return this.get('appName'); | |
} |
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', | |
bar: "bar", | |
baz: "baz", | |
foo: Ember.computed('bar', 'baz', { | |
get (key) { | |
return `${this.get('bar')} ${this.get('baz')}`; | |
}, |