Skip to content

Commit

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

```
ember g route todos/active
rm app/templates/todos/active.hbs
```
  • Loading branch information
chrislopresto committed Mar 12, 2015
1 parent da657eb commit 9ba333f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var Router = Ember.Router.extend({
Router.map(function() {
this.resource('todos', {
path: '/'
}, function() {});
}, function() {
this.route('active');
});
});

export default Router;
12 changes: 12 additions & 0 deletions app/routes/todos/active.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 @@ -24,7 +24,7 @@
<a href="all" class="selected">All</a>
</li>
<li>
<a href="active">Active</a>
{{#link-to "todos.active" activeClass="selected"}}Active{{/link-to}}
</li>
<li>
<a href="completed">Completed</a>
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/routes/todos/active-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/active', {
// 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 9ba333f

Please sign in to comment.