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.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'; | |
// items: [{price: 3.40, qty: 3.134}, {price: 1.39, qty: 2.2}], | |
function totalWithRoundedValue(itemsPropName) { | |
return Ember.computed(`${itemsPropName}.@each.{price,qty}`, function(key) { | |
// Calculate the new total | |
let newTotal = this[itemsPropName] | |
.reduce((tot, item) => tot + (item.price * item.qty), 0); | |
// Create a rounded value as another property | |
Ember.set(this, `${key}Rounded`, Math.round(newTotal * 100) / 100); |
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'; | |
import hbs from 'htmlbars-inline-precompile'; | |
export default Ember.Component.extend({ | |
layout: hbs`{{yield sortedItems}}`, | |
sortedItems: Ember.computed('[email protected]', 'sort', function() { | |
const sort = this.get('sort'); | |
const sorted = [...this.get('data')].sort((a, b) => { | |
if (sort === 'up') return a.id - b.id; | |
return b.id - a.id; |
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({ | |
term: '', | |
init() { | |
this._super(...arguments); | |
this.set('results', []); | |
}, | |
didReceiveAttrs() { | |
this._super(...arguments); |
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({ | |
init() { | |
this._super(...arguments); | |
this.set('list1', [{id: 'a'}, {id: 'b'}, {id: 'c'}]); | |
this.set('list2', [{id: 'a'}, {id: 'b'}, {id: 'c'}]); | |
} | |
}); |
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({ | |
init() { | |
this._super(...arguments); | |
this.set('list1', [{id: 'a'}, {id: 'b'}, {id: 'c'}]); | |
this.set('list2', [{id: 'a'}, {id: 'b'}, {id: 'c'}]); | |
} | |
}); |
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 Component from '@ember/component'; | |
import { set } from '@ember/object'; | |
import { computed } from '@ember-decorators/object'; | |
import hbs from 'htmlbars-inline-precompile'; | |
const WORDS_PER_SEC = 200 / 60; // Assumption: 200 words per minute | |
export class CountingTextareaManager { | |
constructor(str) { | |
this.isDetailShown = true; |
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' | |
}); |