Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Created December 29, 2015 12:32
Show Gist options
  • Save amacgregor/d095165fe3ff1b4fb830 to your computer and use it in GitHub Desktop.
Save amacgregor/d095165fe3ff1b4fb830 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('entry');
},
isExpanded: false,
actions: {
expand() {
this.controller.set('isExpanded', true);
},
contract() {
this.controller.set('isExpanded', false);
}
}
});
{{#each model as |entry|}}
<h2><a href="/entries/{{entry.id}}">{{entry.title}}</a></h2>
<p>{{entry.word_count}} words</p>
{{#if isExpanded}}
<div class='body'>{{entry.content}}</div>
<button {{action 'contract'}}>Contract</button>
{{else}}
<button {{action 'expand'}}>Show More...</button>
{{/if}}
{{/each}}
@4www
Copy link

4www commented Dec 29, 2015

I believe that in this case the problem comes from your isExpanded property.
You have that property referenced in your route when your template can only access properties from this same route's controller.
So I see two solutions:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment