Skip to content

Instantly share code, notes, and snippets.

@piotrpalek
Last active June 10, 2016 15:23
Show Gist options
  • Save piotrpalek/b7509cf50ddb9e33d6fdbdad9bb1d830 to your computer and use it in GitHub Desktop.
Save piotrpalek/b7509cf50ddb9e33d6fdbdad9bb1d830 to your computer and use it in GitHub Desktop.
hash helper
import Ember from 'ember';
export default Ember.Component.extend({
prettyParams: Ember.computed('params', {
get() {
return `${this.get('params.paramA')} && ${this.get('params.paramB')}`;
}
})
});
import Ember from 'ember';
function random() {
return Math.round(Math.random() * 100);
}
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
paramA: random(),
paramB: random(),
actions: {
randomize() {
this.set('paramA', random());
this.set('paramB', random());
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
paramA: {{paramA}}
<br>
paramB: {{paramB}}
<br>
<button onclick={{action "randomize"}}>Randomize</button>
<br>
{{my-component params=(hash paramA=paramA paramB=paramB)}}
{{yield}}
prettyParams: {{prettyParams}}
<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