Created
July 3, 2013 16:59
-
-
Save frankV/5920495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global Todos Ember */ | |
'use strict'; | |
Todos.Router.map(function () { | |
this.resource('todos', { path: '/' }, function () { | |
this.route('active'); | |
this.route('completed'); | |
}); | |
}); | |
Todos.TodosRoute = Ember.Route.extend({ | |
model: function () { | |
return Todos.Todo.find(); | |
} | |
}); | |
Todos.TodosIndexRoute = Ember.Route.extend({ | |
setupController: function () { | |
var todos = Todos.Todo.find(); | |
this.controllerFor('todos').set('filteredTodos', todos); | |
} | |
}); | |
Todos.TodosActiveRoute = Ember.Route.extend({ | |
setupController: function () { | |
var todos = Todos.Todo.filter(function (todo) { | |
if (!todo.get('isCompleted')) { | |
return true; | |
} | |
}); | |
this.controllerFor('todos').set('filteredTodos', todos); | |
} | |
}); | |
Todos.TodosCompletedRoute = Ember.Route.extend({ | |
setupController: function () { | |
var todos = Todos.Todo.filter(function (todo) { | |
if (todo.get('isCompleted')) { | |
return true; | |
} | |
}); | |
this.controllerFor('todos').set('filteredTodos', todos); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment