Skip to content

Instantly share code, notes, and snippets.

@igorstajic
Last active June 14, 2016 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save igorstajic/537e37c6db0f8cab40d4c3f9a15965f0 to your computer and use it in GitHub Desktop.
Save igorstajic/537e37c6db0f8cab40d4c3f9a15965f0 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
myStrings: ['bla', 'asd', 'zzz', 'fgh'],
computedStrings: Ember.computed('myStrings.[]', function() {
return this.get('myStrings')
.map(aString => Ember.String.capitalize(aString));
}),
actions: {
add() {
this.get('myStrings').pushObject('testing');
}
}
});
import Ember from 'ember';
export function sortHelper(params/*, hash*/) {
return params[0].sort();
;
}
export default Ember.Helper.helper(sortHelper);
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<button {{action 'add'}}>Add</button>
<p>Normal property:</p>
{{#each (sort-helper myStrings) as |string|}}
{{string}}
{{/each}}
<p>Computed property:</p>
{{#each (sort-helper computedStrings) as |string|}}
{{string}}
{{/each}}
<br>
<br>
{
"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