Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeroicEric/9259588 to your computer and use it in GitHub Desktop.
Save HeroicEric/9259588 to your computer and use it in GitHub Desktop.
<dl class="sub-nav">
<dt>Filter:</dt>
{{#link-to 'challenges' (query-params complete=false) tagName='dd'}}
<a {{bind-attr href="view.href"}}>All</a>
{{/link-to}}
{{#link-to 'challenges' (query-params complete=true) tagName='dd'}}
<a {{bind-attr href="view.href"}}>Complete</a>
{{/link-to}}
{{! How to get this one work, ie actually pass `false` to filter}}
{{#link-to 'challenges' (query-params complete=false) tagName='dd'}}
<a {{bind-attr href="view.href"}}>Incomplete</a>
{{/link-to}}
</dl>
<ul>
{{#each filteredChallenges}}
<li>{{name}} / {{isComplete}}</li>
{{/each}}
</ul>
export default Ember.ArrayController.extend({
queryParams: ['complete'],
complete: null,
filteredChallenges: function() {
var complete = this.get('complete');
var challenges = this.get('model');
if (complete) {
return challenges.filterProperty('isComplete', true);
} else {
return challenges;
}
}.property('complete', 'model')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment