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.Component.extend({ | |
// this will work like a charm | |
computedTotalTask: Ember.computed.alias('model.length'), | |
didReceiveAttrs(){ | |
// below will work on initial assignment; not later on because model is not updated | |
// only elements are added or removed |
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.Component.extend({ | |
actions: { | |
onclick() { | |
// Toggle object's property so that the observer will execute! | |
this.get('object').toggleProperty('dummyVariable'); | |
} | |
} | |
}); |
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.Component.extend({ | |
isBlankSelected: Ember.computed.empty('selectedOption'), | |
actions: { | |
loadFilter(selectedOption) { | |
this.set('selectedOption', selectedOption); | |
} | |
} |
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.Component.extend({ | |
selected: {name: 'All', id:0}, | |
computedOptions: Ember.computed('options.[]', function(){ | |
return this.get('options').slice().insertAt(0, this.get('selected')); | |
}) | |
}); |
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.Component.extend({ | |
categories: { | |
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'], | |
'Ryes': ['WhistlePig', 'High West'] | |
}, | |
actions: { | |
additem() { |
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.Component.extend({ | |
categories: { | |
'Bourbons': ['Bulleit', 'Four Roses', 'Woodford Reserve'], | |
'Ryes': ['WhistlePig', 'High West'] | |
}, | |
actions: { | |
additem() { |
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({ | |
appName: 'Ember Twiddle', | |
}); |
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.Component.extend({ | |
myService: Ember.inject.service(), | |
actions: { | |
incrementTotal() { | |
let total = this.get('myService').getTotal(); | |
total = Ember.isBlank(total) ? 0 : total; | |
this.get('myService').setTotal(total+1); |
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.Component.extend({ | |
actions: { | |
removeFromDOM() { | |
this.$().remove(); | |
} | |
} | |
}); |
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.Component.extend({ | |
myService: Ember.inject.service(), | |
didDestroyElement() { | |
console.log('@didDestroyElement'); | |
}, | |
willDestroyElement() { |