Commit 7496c95e authored by Christoph Burgdorf's avatar Christoph Burgdorf

added todo counter

parent 35636594
...@@ -2,3 +2,12 @@ ...@@ -2,3 +2,12 @@
#main { #main {
display: block; display: block;
} }
#todoapp footer{
display: block;
}
/*this doesn't seemed to be used in the jquery example at all. Its getting in the way */
#todo-count span {
font-weight: inherit;
}
\ No newline at end of file
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
</li> </li>
</ul> </ul>
</section> </section>
<footer> <footer ng:show="hasTodos()">
<a id="clear-completed">Clear completed</a> <a id="clear-completed">Clear completed</a>
<div id="todo-count"></div> <div id="todo-count"><b>{{ remainingTodos() }}</b> {{ itemsLeftText() }}</div>
</footer> </footer>
</div> </div>
<div id="instructions"> <div id="instructions">
......
...@@ -42,10 +42,18 @@ App.Controllers.TodoController = function () { ...@@ -42,10 +42,18 @@ App.Controllers.TodoController = function () {
} }
}; };
var pluralize = function( count, word ) {
return count === 1 ? word : word + 's';
}
self.remainingTodos = countTodos("undone"); self.remainingTodos = countTodos("undone");
self.finishedTodos = countTodos("done"); self.finishedTodos = countTodos("done");
self.itemsLeftText = function(){
return pluralize(self.remainingTodos(), 'item' ) + ' left'
};
self.clearCompletedItems = function() { self.clearCompletedItems = function() {
var oldTodos = self.todos; var oldTodos = self.todos;
self.todos = []; self.todos = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment