Created
June 5, 2016 22:46
-
-
Save jelhan/a39c567b4f7755bece2efb640a06b19b to your computer and use it in GitHub Desktop.
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({ | |
classNameBindings: ['clicked'], | |
tagName: 'button', | |
click() { | |
this.set('clicked', true); | |
} | |
}); |
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({ | |
actions: { | |
addItem() { | |
this.get('items').pushObject({ | |
name: 'new' | |
}); | |
}, | |
changeItemProperty() { | |
this.set('items.firstObject.name', 'changed'); | |
}, | |
deleteItem() { | |
this.get('items').removeAt(0); | |
} | |
}, | |
items: Ember.A([ | |
{ name: 'foo' }, | |
{ name: 'bar' } | |
]), | |
arrayProxy: Ember.computed('items.[]', function() { | |
return Ember.ArrayProxy.create({ | |
content: this.get('items'), | |
objectAtContent: function(idx) { | |
let obj = Ember.copy(this.get('content').objectAt(idx)); | |
Ember.set(obj, 'name', 'test'); | |
return obj; | |
} | |
}); | |
}), | |
filterItems: Ember.computed.filter('items', function(item) { | |
return true; | |
}), | |
mapItems: Ember.computed.map('items', function(item) { | |
return Ember.ObjectProxy.create({ | |
content: item | |
}); | |
}), | |
mapByItems: Ember.computed.mapBy('items', 'name'), | |
mapByFakeItems: Ember.computed.map('items', item => item.name), | |
sortItems: Ember.computed.sort('items', function(a, b) { | |
if (a.name > b.name) { | |
return 1; | |
} else if (a.name < b.name) { | |
return -1; | |
} | |
return 0; | |
}) | |
}); |
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
.clicked { | |
background-color: yellow; | |
} |
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.8.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment