Skip to content

Commit 2497c5e

Browse files
committed
Pass an isSelected property down to the tag
1 parent 2de9b24 commit 2497c5e

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/redux/components/Todo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</span>
2525
</div>
2626
<div style="display:inline-block">
27-
<todo-tags (tagSelected)="filterOnTag($event)" [tags]="tags"></todo-tags>
27+
<todo-tags (tagSelected)="filterOnTag($event)" [tags]="tags" [selectedTag]="tagFilter"></todo-tags>
2828
</div>
2929
</div>
3030

src/redux/components/TodoTags/TodoTag.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {CORE_DIRECTIVES} from 'angular2/common';
55
selector: 'todo-tag',
66
template: `
77
<div (click)="tagClick()" style="display:inline-block; cursor:pointer; border-radius:5px;
8-
color:gold; background-color:black; padding:5px">{{tag}}</div>
8+
color:gold; background-color:black; padding:5px">{{tag}} - {{isSelected}}</div>
99
`,
1010
directives: [CORE_DIRECTIVES]
1111
})
1212

1313
export class TodoTag {
1414

1515
@Input() tag: string;
16+
@Input() isSelected: boolean;
1617
@Output() tagClicked: EventEmitter<string> = new EventEmitter<string>();
1718

1819
ngOnInit() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div style="display:inline-block">
2-
<todo-tag (tagClicked)="tagClicked($event)" [tag]="t" *ngFor="#t of tags | async"></todo-tag>
2+
<todo-tag (tagClicked)="tagClicked($event)" [tag]="t" [isSelected]="t === selectedTag" *ngFor="#t of tags | async"></todo-tag>
33
</div>

src/redux/components/TodoTags/TodoTags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {TodoTag} from './TodoTag';
1313
export class TodoTags {
1414

1515
@Input() tags: Observable<string[]>;
16+
@Input() selectedTag: string;
1617
@Output() tagSelected: EventEmitter<string> = new EventEmitter<string>();
1718

1819
tagClicked(tag:string) {

0 commit comments

Comments
 (0)