Thuta Learning
Angular
ProjectsWeb DevelopmentIntermediate

Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)

AngularLesson 4630 min

What you'll walk away with

  • Explain the core concept and Angular data flow of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)
  • Run the example, predict its state and UI, and test edge and error cases
  • Apply a typed safe pattern in a real project and recognize common pitfalls

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.

Mental model
  1. project requirements
  2. components, state, and services
  3. tested UI

Explain the core concept and Angular data flow of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)

Core syntax or pattern

typescript
// 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

  1. project requirements// task-count.pipe.ts

    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.

  2. components, state, and servicesimport { 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.

  3. tested UI};

    Add a validated local-storage adapter, editing flow, responsive styles, and tests; cover reload, corrupt storage, keyboard-only use, and mobile width.

Execution flow
  1. project requirements
  2. components, state, and services
  3. 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

typescript
// 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('/');
    })
  );
};
You should see
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
typescript
// 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

What best describes the core idea of Mini Project: Task Tracker (Part 3 - Polish & Wrap-up)?

Quick quiz 2 / 3

Which mistake should you avoid first?

Quick quiz 3 / 3

How should this be applied in a real project?

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

Easy traps

  • Showing success without handling storage read or write failures can hide lost user data.
  • One happy-path result does not prove the feature works; empty, loading, error, and cleanup behavior need explicit tests.

Hands-on Exercise

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.

You'll know it worked when: 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.

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Mini Project: Task Tracker (Part 3 - Polish & Wrap-up) | Thuta Learning