|
|
@@ -15,8 +15,7 @@ Seed.controller('Todos', function (scope) {
|
|
|
updateFilter()
|
|
|
window.addEventListener('hashchange', updateFilter)
|
|
|
function updateFilter () {
|
|
|
- if (!location.hash) return
|
|
|
- scope.filter = location.hash.slice(2) || 'all'
|
|
|
+ scope.filter = location.hash ? location.hash.slice(2) : 'all'
|
|
|
}
|
|
|
|
|
|
// regular properties -----------------------------------------------------
|
|
|
@@ -34,10 +33,6 @@ Seed.controller('Todos', function (scope) {
|
|
|
return scope.total - scope.remaining
|
|
|
}}
|
|
|
|
|
|
- scope.itemLabel = {get: function () {
|
|
|
- return scope.remaining > 1 ? 'items' : 'item'
|
|
|
- }}
|
|
|
-
|
|
|
// dynamic context computed property using info from target scope
|
|
|
scope.filterTodo = {get: function (e) {
|
|
|
return filters[scope.filter](e.scope.completed)
|
|
|
@@ -63,7 +58,7 @@ Seed.controller('Todos', function (scope) {
|
|
|
|
|
|
// event handlers ---------------------------------------------------------
|
|
|
scope.addTodo = function () {
|
|
|
- var value = scope.newTodo.trim()
|
|
|
+ var value = scope.newTodo && scope.newTodo.trim()
|
|
|
if (value) {
|
|
|
scope.todos.unshift({ title: value, completed: false })
|
|
|
scope.newTodo = ''
|