Skip to content

Commit 1b2f49d

Browse files
author
Benjamin Hahn
committed
fix(tomastrajan#524): class active on Todos filter not showing up
1 parent 7599a91 commit 1b2f49d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

projects/angular-ngrx-material-starter/src/app/features/examples/todos/components/todos-container.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ <h2 class="dotos-title" rtl>
2323
<fa-icon icon="filter"></fa-icon>
2424
</button>
2525
<mat-menu class="todos-filter-menu-overlay" #todosFilter="matMenu" xPosition="before">
26-
<button mat-menu-item (click)="onFilterTodos('ALL')" [ngClass]="{ active: todos.filter === 'ALL' }" rtl>
26+
<button mat-menu-item (click)="onFilterTodos('ALL')" [class.active]="(filter$ | async) === 'ALL'" rtl>
2727
<mat-icon>
2828
<fa-icon icon="tasks"></fa-icon>
2929
</mat-icon>
3030
<span>{{ 'anms.examples.todos.filter.all' | translate }}</span>
3131
</button>
32-
<button mat-menu-item (click)="onFilterTodos('DONE')" [ngClass]="{ active: todos.filter === 'DONE' }">
32+
<button mat-menu-item (click)="onFilterTodos('DONE')" [class.active]="(filter$ | async) === 'DONE'">
3333
<mat-icon>
3434
<fa-icon icon="check"></fa-icon>
3535
</mat-icon>
3636
<span>{{ 'anms.examples.todos.filter.done' | translate }}</span>
3737
</button>
38-
<button mat-menu-item (click)="onFilterTodos('ACTIVE')" [ngClass]="{ active: todos.filter === 'ACTIVE' }">
38+
<button mat-menu-item (click)="onFilterTodos('ACTIVE')" [class.active]="(filter$ | async) === 'ACTIVE'">
3939
<mat-icon>
4040
<fa-icon icon="square"></fa-icon>
4141
</mat-icon>

projects/angular-ngrx-material-starter/src/app/features/examples/todos/components/todos-container.component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { selectTodosFilter } from './../todos.selectors';
12
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
23
import { TranslateService } from '@ngx-translate/core';
34
import { MatSnackBar } from '@angular/material/snack-bar';
@@ -23,6 +24,7 @@ import { Todo, TodosFilter } from '../todos.model';
2324
export class TodosContainerComponent implements OnInit {
2425
routeAnimationsElements = ROUTE_ANIMATIONS_ELEMENTS;
2526
todos$: Observable<Todo[]>;
27+
filter$: Observable<TodosFilter>;
2628
removeDoneDisabled$: Observable<boolean>;
2729
newTodo = '';
2830

@@ -35,6 +37,7 @@ export class TodosContainerComponent implements OnInit {
3537

3638
ngOnInit() {
3739
this.todos$ = this.store.pipe(select(selectTodos));
40+
this.filter$ = this.store.pipe(select(selectTodosFilter));
3841
this.removeDoneDisabled$ = this.store.pipe(
3942
select(selectRemoveDoneTodosDisabled)
4043
);

0 commit comments

Comments
 (0)