Skip to content

Commit

Permalink
Display the number of incomplete todos
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislopresto committed Mar 12, 2015
1 parent f96776d commit 9156092
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/controllers/todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@ export default Ember.ArrayController.extend({
// Save the new model
todo.save();
}
}
},

remaining: function() {
return this.filterBy('isCompleted', false).get('length');
}.property('@each.isCompleted'),

inflection: function() {
var remaining = this.get('remaining');
return remaining === 1 ? 'item' : 'items';
}.property('remaining')

});
2 changes: 1 addition & 1 deletion app/templates/todos.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<footer id="footer">
<span id="todo-count">
<strong>2</strong> todos left
<strong>{{remaining}}</strong> {{inflection}} left
</span>
<ul id="filters">
<li>
Expand Down

0 comments on commit 9156092

Please sign in to comment.