Skip to content

Instantly share code, notes, and snippets.

@jelhan
Created July 16, 2018 22:28
Show Gist options
  • Save jelhan/02ec0cc744a980e3aad2885977cea3d2 to your computer and use it in GitHub Desktop.
Save jelhan/02ec0cc744a980e3aad2885977cea3d2 to your computer and use it in GitHub Desktop.
Stackoverflow 51335491
import Ember from 'ember';
import { computed } from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
dynamicPart: 'foo',
row: computed(() => {
return {
'foo': {
'key': 'foo value'
},
'bar': {
'key': 'bar value'
}
};
})
});
<h1>Composition of get and concat helpers</h1>
<p>A proof of concept for <a href="https://stackoverflow.com/questions/51335491/how-do-i-access-object-property-in-handlebars-template">this StackOverflow question</a>.</p>
<p>
{{get row (concat dynamicPart '.key')}}
<br>
<button onclick={{action (mut dynamicPart) 'bar'}}>show bar value</button>
</p>
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment