Skip to content

Commit

Permalink
Transition to show only complete todos
Browse files Browse the repository at this point in the history
http://guides.emberjs.com/v1.10.0/getting-started/show-only-complete-todos/

```
ember g route todos/completed
rm app/templates/todos/completed.hbs
```
  • Loading branch information
chrislopresto committed Mar 12, 2015
1 parent 9ba333f commit 2a3ef1c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Router.map(function() {
path: '/'
}, function() {
this.route('active');
this.route('completed');
});
});

Expand Down
12 changes: 12 additions & 0 deletions app/routes/todos/completed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Ember from 'ember';

export default Ember.Route.extend({
model: function(){
return this.store.filter('todo', function(todo) {
return todo.get('isCompleted');
});
},
renderTemplate: function(controller) {
this.render('todos/index', {controller: controller});
}
});
2 changes: 1 addition & 1 deletion app/templates/todos.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{#link-to "todos.active" activeClass="selected"}}Active{{/link-to}}
</li>
<li>
<a href="completed">Completed</a>
{{#link-to "todos.completed" activeClass="selected"}}Completed{{/link-to}}
</li>
</ul>

Expand Down
14 changes: 14 additions & 0 deletions tests/unit/routes/todos/completed-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
moduleFor,
test
} from 'ember-qunit';

moduleFor('route:todos/completed', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
var route = this.subject();
assert.ok(route);
});

0 comments on commit 2a3ef1c

Please sign in to comment.