Skip to main content
Angular is a comprehensive framework from Google for building web applications. This guide shows you how to integrate Angular with Mizu as the backend.

Why Angular?

Angular is a full-featured, opinionated framework that provides everything you need to build large-scale applications. Unlike libraries like React or Vue, Angular is a complete platform with a rich ecosystem of official tools and patterns. Key strengths:
  • Complete platform: Router, HTTP, Forms, Testing all included
  • TypeScript-first: Built with and for TypeScript
  • Dependency Injection: Enterprise-grade DI system
  • RxJS: Powerful reactive programming
  • Signals: New reactive primitives (Angular 16+)
  • CLI: World-class tooling and scaffolding
  • Consistency: Strong opinions lead to consistent code
  • Enterprise-ready: Battle-tested at Google scale

Angular vs Other Frameworks

Angular + Mizu vs Standalone Angular

Quick Start

Visit http://localhost:4200 to see your app!

Architecture

Development Mode

Production Mode

Project Structure

Backend Setup

Important: Angular’s output path includes the project name: dist/my-app/browser/

API Routes Example

Angular Configuration

frontend/angular.json

frontend/proxy.conf.json

This proxies /api/* requests to the Mizu backend during development.

Frontend Setup

frontend/src/app/app.routes.ts

frontend/src/app/app.config.ts

frontend/src/app/app.component.ts

frontend/src/app/pages/home/home.component.ts

Standalone Components

Angular 14+ introduced standalone components, eliminating the need for NgModules for most apps.

Creating Standalone Components

Component Communication

Services and Dependency Injection

Angular’s DI system is one of its most powerful features.

Creating a Service

Using Services in Components

Service Scopes

Signals (Angular 16+)

Signals are Angular’s new reactive primitives for fine-grained reactivity.

Basic Signals

Signals in Services

RxJS and Observables

Angular uses RxJS extensively for async operations.

Common RxJS Operators

Common Patterns

Reactive Forms

Angular’s reactive forms provide fine-grained control over form state and validation.

Basic Reactive Form

Advanced Forms with FormArray

Custom Validators

Routing

Angular Router provides powerful routing capabilities.

Nested Routes

Route Parameters

Programmatic Navigation

Route Guards

Route Resolvers

Pipes

Pipes transform data in templates.

Built-in Pipes

Custom Pipes

Directives

Directives modify element behavior.

Structural Directives

Attribute Directives

HTTP Interceptors

Interceptors modify HTTP requests and responses globally.

Lifecycle Hooks

Angular components have a rich lifecycle.
Lifecycle order:
  1. ngOnChanges() - Input changes
  2. ngOnInit() - Component initialized
  3. ngDoCheck() - Change detection
  4. ngAfterContentInit() - Content initialized
  5. ngAfterContentChecked() - Content checked
  6. ngAfterViewInit() - View initialized
  7. ngAfterViewChecked() - View checked
  8. ngOnDestroy() - Before destruction

ViewChild and ContentChild

Access child components and DOM elements.

Lazy Loading

Load feature modules on demand to reduce initial bundle size.

Complete Real-World Example: Task Manager

Let’s build a complete task management application.

Backend (Go)

Frontend - Service

Frontend - Components

Development Workflow

Or:
Visit http://localhost:4200 during development.

Building for Production

This:
  1. Builds Angular (ng build --configuration=production)
  2. Builds Go binary with embedded frontend
Run:

Troubleshooting

Build Path Issues

Problem: Go can’t find the Angular dist folder. Solution: Angular outputs to dist/my-app/browser (project name included):

Proxy Not Working

Problem: API calls fail in development. Solution: Check proxy.conf.json is configured and referenced in angular.json:

Zone.js Errors

Problem: “Zone is not defined” error. Solution: Ensure zone.js is in polyfills:

Signal Not Updating

Problem: Signal changes don’t trigger updates. Solution: Use .set() or .update(), not direct assignment:

When to Choose Angular

Choose Angular if:
  • You’re building enterprise-scale applications
  • You want a complete, opinionated framework
  • You value TypeScript and strong typing
  • You need powerful dependency injection
  • Your team prefers structure and conventions
  • You want official solutions for common problems
Consider alternatives if:
  • React: You need maximum flexibility or have a React ecosystem requirement
  • Vue: You want easier learning curve with similar features
  • Svelte: You need smallest bundle size and compile-time optimization
  • HTMX/Alpine: You prefer server-rendered HTML with minimal JavaScript

Next Steps

React Guide

Try React instead

Angular Docs

Official Angular documentation

API Integration

Best practices for APIs

Deployment

Build and deploy