Instantly share code, notes, and snippets.

View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super();
this.set('bar', { foo: 'stuff' });
this.set('keys', Object.keys(Ember.get(this, 'bar')));
},
actions: {
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super();
this.set('bar', { foo: 'stuff' });
},
actions: {
foo() {
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
alert('saving ' + this.get('foo'));
}
}
});
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
updateCount: 0,
didUpdateAttrs() {
this._super(...arguments)
console.log("didUpdateAttrs", this.updateCount)
debugger
this.updateCount++;
}
View components.x-inner.js
import Ember from 'ember';
let uuid = 0;
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.count = 0;
},
View controllers.application.js
import Ember from 'ember';
let RowItem = Ember.Object.extend({
order: 0
});
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
sortDirection: 'asc',
items: Ember.computed(function(){
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
updateValue(event) {
let newValue = event.target.value;
let sanitizedValue = newValue.replace(/[^a-zA-Z0-9-]/, '');
if (newValue !== sanitizedValue) {
event.target.value = sanitizedValue;
}
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
log(msg) {
alert(msg);
}
}
View controllers.application.js
import Ember from 'ember';
import DS from 'ember-data';
import MyNativeClassModel from '../models/my-native-class-model';
import MyEmberObjectModel from '../models/my-ember-object-model';
function isModel(TestModel) {
return TestModel !== DS.Model && DS.Model.detect(TestModel);
}
export default Ember.Controller.extend({
View controllers.application.js
import Ember from 'ember';
const Controller = Ember.Controller.extend({
appName: 'Ember Twiddle',
_foo: 0,
bar: 0,
// foo: Ember.computed({
// get() {