Explain it simply
Mini Project: Task Tracker (Part 3 - Polish & Wrap-up), in plain language
Part 3 is the project's final stage — once the core features are done, we'll add polish that improves user experience and code quality. The custom pipe, async pipe, form validation, and route guard lessons apply directly to this stage. We'll round out the app by formatting the task count summary with a custom pipe, switching to the async pipe to avoid manual subscribe/unsubscribe leaks in the template, adding validation so the title field can't be empty, and using a guard to block access to the detail page when a task ID isn't found.
Problem → Why → Solution
The problem — why this concept matters
Showing success without handling storage read or write failures can hide lost user data.
A common mistake
One happy-path result does not prove the feature works; empty, loading, error, and cleanup behavior need explicit tests.
Core concept — understand how it works
Part 3 turns the demo into a complete feature with persistence, accessibility, responsive UX, error handling, and tests. Version and validate stored data, provide a fallback for corruption, and surface save failures. Verify keyboard focus, semantic controls, empty and loading states, critical user flows, and a clean production build.
- project requirements
- components, state, and services
- tested UI
Explain the core concept and Angular data flow of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)
Core syntax or pattern
// task-count.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { Task } from './task.model';
@Pipe({ name: 'taskCount' })
export class TaskCountPipe implements PipeTransform {
transform(tasks: Task[]): string {
const completed = tasks.filter(t => t.completed).length;
return `${completed}/${tasks.length} completed`;
}
}
// task-exists.guard.ts
import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { TaskService } from './task.service';
import { map, take } from 'rxjs/operators';
export const taskExistsGuard: CanActivateFn = (route) => {
const taskService = inject(TaskService);
const router = inject(Router);
const id = Number(route.paramMap.get('id'));
return taskService.tasks$.pipe(
take(1),
map(tasks => {
const found = tasks.some(t => t.id === id);
return found ? true : router.parseUrl('/');
})
);
};Part 3 turns the demo into a complete feature with persistence, accessibility, responsive UX, error handling, and tests. Version and validate stored data, provide a fallback for corruption, and surface save failures. Verify keyboard focus, semantic controls, empty and loading states, critical user flows, and a clean production build.
Read the code step by step
- project requirements
// task-count.pipe.tsPart 3 is the project's final stage — once the core features are done, we'll add polish that improves user experience and code quality. The custom pipe, async pipe, form validation, and route guard lessons apply directly to this stage. We'll round out the app by formatting the task count summary with a custom pipe, switching to the async pipe to avoid manual subscribe/unsubscribe leaks in the template, adding validation so the title field can't be empty, and using a guard to block access to the detail page when a task ID isn't found.
- components, state, and services
import { TaskService } from './task.service';Part 3 turns the demo into a complete feature with persistence, accessibility, responsive UX, error handling, and tests. Version and validate stored data, provide a fallback for corruption, and surface save failures. Verify keyboard focus, semantic controls, empty and loading states, critical user flows, and a clean production build.
- tested UI
};Add a validated local-storage adapter, editing flow, responsive styles, and tests; cover reload, corrupt storage, keyboard-only use, and mobile width.
- project requirements
- components, state, and services
- tested UI
Success
Explain the core concept and Angular data flow of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)
Failure
Showing success without handling storage read or write failures can hide lost user data.
Let's think about this for a moment
Part 3 is the project's final stage — once the core features are done, we'll add polish that improves user experience and code quality. The custom pipe, async pipe, form validation, and route guard lessons apply directly to this stage. We'll round out the app by formatting the task count summary with a custom pipe, switching to the async pipe to avoid manual subscribe/unsubscribe leaks in the template, adding validation so the title field can't be empty, and using a guard to block access to the detail page when a task ID isn't found.
Let's build it for real
Build a custom pipe called `TaskCountPipe` and write a transform() that returns text like "3/5 completed". In the TaskListComponent template, bind the tasks$ Observable directly with the `| async` pipe and remove the manual subscribe(). Add Validators.required to the title field of the task form, and disable the submit button when it's invalid. Build a `taskExistsGuard` CanActivate guard that checks whether a task exists for the id parameter on the TaskDetailComponent route, and redirects back to the root path if it doesn't. Finally, write a README.md that summarizes the project.
Code Example
// task-count.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { Task } from './task.model';
@Pipe({ name: 'taskCount' })
export class TaskCountPipe implements PipeTransform {
transform(tasks: Task[]): string {
const completed = tasks.filter(t => t.completed).length;
return `${completed}/${tasks.length} completed`;
}
}
// task-exists.guard.ts
import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { TaskService } from './task.service';
import { map, take } from 'rxjs/operators';
export const taskExistsGuard: CanActivateFn = (route) => {
const taskService = inject(TaskService);
const router = inject(Router);
const id = Number(route.paramMap.get('id'));
return taskService.tasks$.pipe(
take(1),
map(tasks => {
const found = tasks.some(t => t.id === id);
return found ? true : router.parseUrl('/');
})
);
};When you reload the app, a completed-count summary shows up on the list, submitting without a title is blocked, and navigating directly to a nonexistent task id via the URL redirects back to the root page.Real-world usage
How to apply it in a real project
Add a validated local-storage adapter, editing flow, responsive styles, and tests; cover reload, corrupt storage, keyboard-only use, and mobile width.
Mini challenge
Build it yourself
Rebuild the Mini Project: Task Tracker (Part 3 - Polish & Wrap-up) example without copying it. Add two normal states, one edge case, and one failure state, and write the expected UI and state transition before running it.
- Rebuild the example without copying it
- Test a normal input and an edge case
- Predict the compiler or output result before running it
// task-count.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { Task } from './task.model';
@Pipe({ name: 'taskCount' })
export class TaskCountPipe implements PipeTransform {
transform(tasks: Task[]): string {
const completed = tasks.filter(t => t.completed).length;
return `${completed}/${tasks.length} completed`;
}
}
// task-exists.guard.ts
import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { TaskService } from './task.service';
import { map, take } from 'rxjs/operators';
export const taskExistsGuard: CanActivateFn = (route) => {
const taskService = inject(TaskService);
const router = inject(Router);
const id = Number(route.paramMap.get('id'));
return taskService.tasks$.pipe(
take(1),
map(tasks => {
const found = tasks.some(t => t.id === id);
return found ? true : router.parseUrl('/');
})
);
};Expected: Explain the core concept and Angular data flow of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)
Show hint
Add a validated local-storage adapter, editing flow, responsive styles, and tests; cover reload, corrupt storage, keyboard-only use, and mobile width.
Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- project requirements → components, state, and services → tested UI
- Part 3 turns the demo into a complete feature with persistence, accessibility, responsive UX, error handling, and tests. Version and validate stored data, provide a fallback for corruption, and surface save failures. Verify keyboard focus, semantic controls, empty and loading states, critical user flows, and a clean production build.
- Showing success without handling storage read or write failures can hide lost user data.
- Add a validated local-storage adapter, editing flow, responsive styles, and tests; cover reload, corrupt storage, keyboard-only use, and mobile width.
Angular — Overview — Angular