Skip to content

Commit e71900b

Browse files
committed
filtering inside todo-list component
1 parent a95ee8b commit e71900b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div ng-repeat="todoItem in $ctrl.todoItems">
1+
<div ng-repeat="todoItem in $ctrl.todoItems | filter:$ctrl.filterBy">
22
<span>{{ todoItem.title }}</span>
33
</div>

src/app/todos/components/todo-list/todo-list.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export class TodoList implements angular.IComponentOptions {
77
constructor() {
88
this.template = require('./todo-list.component.html');
99
this.bindings = {
10-
todoItems: '<'
10+
todoItems: '<',
11+
filterBy: '<'
1112
};
1213
}
1314
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
<h2>All items</h2>
2-
<todo-list todo-items="$ctrl.todoItems"></todo-list>
1+
<uib-tabset>
2+
<uib-tab index="0" heading="All">
3+
<todo-list todo-items="$ctrl.todoItems"></todo-list>
4+
</uib-tab>
5+
<uib-tab index="1" heading="Completed">
6+
<todo-list todo-items="$ctrl.todoItems" filter-by="{completed:true}"></todo-list>
7+
</uib-tab>
8+
</uib-tabset>

src/app/todos/services/TodoStorageService.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { TodoItem } from './../models/TodoItem';
33
export class TodoStorageService {
44

55
todoItems: TodoItem[] = [
6-
new TodoItem('Vuilbakken', false),
7-
new TodoItem('Afwas', true)
6+
new TodoItem('Todo Item 1', false),
7+
new TodoItem('Todo Item 2', true),
8+
new TodoItem('Todo Item 3', true),
9+
new TodoItem('Todo Item 4', false)
810
];
911

1012
constructor(private $q: angular.IQService) { }

0 commit comments

Comments
 (0)