Angular Development Tutorials

This website is Brian Treese's Angular Development Blog. The site provides practical, hands-on tutorials and resources for developers who use the Angular framework. The tutorials cover modern Angular techniques including Signals, Components, Forms, Animations, CDK (Component Dev Kit), and Styling. Each tutorial includes code examples, video demonstrations, and step-by-step instructions to help you build Angular applications.

Angular Component Styling: Every Way to Add Styles (Complete Guide)

Angular Component Styling: Every Way to Add Styles (Complete Guide)

March 06, 2025

Angular offers multiple ways to add styles to components, each with different use cases and trade-offs. From inline styles in the decorator to external stylesheets, from programmatic styling with Renderer2 to CSS custom properties, choosing the right approach impacts maintainability and performance. This comprehensive guide walks through every styling method available in Angular, helping you make informed decisions for your components.

Angular Component Theming: CSS Custom Properties and :host-context

Angular Component Theming: CSS Custom Properties and :host-context

February 27, 2025

Component theming in Angular requires understanding how styles cascade and how to adapt components to different contexts. This tutorial demonstrates multiple theming strategies using CSS :host and :host-context selectors, along with CSS custom properties. You'll learn how to create flexible components that adapt their appearance based on where they're used, whether in a sidebar, main content area, or different color schemes. Each approach has trade-offs that we'll explore in detail.

Angular View vs Content: Understanding Signal Queries

Angular View vs Content: Understanding Signal Queries

February 20, 2025

The difference between "view" and "content" in Angular trips up many developers, leading to queries that don't work as expected. Understanding this distinction is crucial for working with signal queries like viewChild() and contentChild(). This tutorial explains the fundamental difference: "view" refers to a component's own template, while "content" refers to projected content from parent components. You'll learn when to use each query type and how to avoid common mistakes.

Untagged Template Literals... The Upgrade You Didn’t Know You Needed!

Untagged Template Literals... The Upgrade You Didn’t Know You Needed!

February 13, 2025

Dynamic class and style bindings in Angular templates often become complex, mixing string concatenation, ternary operators, and multiple bindings that are hard to read and maintain. Angular's template literal syntax provides a cleaner way to handle dynamic expressions, allowing you to use JavaScript template literals directly in templates for classes, styles, and complex interpolations. This tutorial demonstrates how to use template literals to simplify dynamic bindings and improve template readability.

Angular Content Projection: Complete Guide to ng-content and Slots

Angular Content Projection: Complete Guide to ng-content and Slots

February 06, 2025

Content projection is one of Angular's most powerful features for building flexible, reusable components. Instead of hardcoding content inside components, you can create "slots" where parent components inject their own content. This tutorial covers everything from basic single-slot projection to advanced multi-slot patterns and fallback content. You'll learn how to build components that adapt to different use cases without duplicating code.

Angular Component Selectors: Complete Guide to Element, Attribute, and Class Selectors

Angular Component Selectors: Complete Guide to Element, Attribute, and Class Selectors

January 30, 2025

Choosing the wrong component selector in Angular creates maintenance issues, breaks encapsulation, and limits component flexibility. Angular supports three selector types—element, attribute, and class—each with different use cases and trade-offs. This tutorial demonstrates all component selector options in Angular, helping you choose the right selector for your component based on reusability, styling needs, and integration requirements.

Angular ::ng-deep Alternatives Part 2: CSS Custom Properties and View Encapsulation

Angular ::ng-deep Alternatives Part 2: CSS Custom Properties and View Encapsulation

January 16, 2025

Replacing ::ng-deep requires understanding CSS Custom Properties, View Encapsulation modes, and component architecture patterns. This follow-up tutorial addresses common misconceptions about avoiding ::ng-deep and provides specific, production-ready examples using CSS Custom Properties and View Encapsulation settings. You'll learn why ::ng-deep is discouraged by the Angular team and practical alternatives that maintain component boundaries while allowing necessary style customization.

Angular SVG Components: Create Dynamic Interactive Graphics

Angular SVG Components: Create Dynamic Interactive Graphics

January 09, 2025

SVG components in Angular unlock powerful possibilities for data visualization and interactive graphics. Unlike static images, SVG components can respond to data changes, user interactions, and state updates in real time. This tutorial shows you how to transform basic lists into dynamic, interactive SVG charts using Angular's component system, signal-based reactivity, and template binding. You'll learn how to create scalable, data-driven visualizations that update automatically.

Angular Deferred Loading with Animations: Performance and UX (v19+)

Angular Deferred Loading with Animations: Performance and UX (v19+)

January 02, 2025

Loading content users never see wastes bandwidth and slows initial page loads, hurting performance metrics and user experience. Angular's deferred loading feature lets you load components only when they're needed, reducing initial bundle size and improving Core Web Vitals. This tutorial demonstrates how to combine deferred loading with animations, creating smooth transitions as components enter the viewport. Note: This uses Angular's deprecated animations module—modern alternatives are available.

Angular Form Validation: Complete Guide to Validators and Error Handling

Angular Form Validation: Complete Guide to Validators and Error Handling

December 27, 2024

Form validation is crucial for creating great user experiences in Angular applications. Without proper validation, users struggle with unclear errors, incomplete submissions, and frustrating experiences. This tutorial shows you how to implement comprehensive form validation using Angular Reactive Forms, including required fields, email validation, and real-time error messages. You'll learn how to display helpful feedback and prevent invalid submissions.

Angular ::ng-deep Alternatives: Modern Styling Approaches

Angular ::ng-deep Alternatives: Modern Styling Approaches

December 20, 2024

The deprecated ::ng-deep selector was Angular's way to break style encapsulation, but it causes maintenance issues, breaks encapsulation principles, and is no longer supported. Modern Angular provides better alternatives using CSS Custom Properties and View Encapsulation settings that maintain component boundaries while allowing necessary style overrides. This tutorial shows you how to replace ::ng-deep with maintainable, future-proof styling approaches that work with Angular's component architecture.

Angular Expand/Collapse Animation: Animate Height Changes (Deprecated Module)

Angular Expand/Collapse Animation: Animate Height Changes (Deprecated Module)

December 13, 2024

Expand and collapse animations make Angular UIs feel polished and professional. This tutorial demonstrates how to animate height changes using Angular's deprecated animations module. While this approach still works, modern Angular (v19+) offers better alternatives using CSS animations and DOM events. You'll learn the legacy approach here, but for new projects, consider using pure CSS transitions or Angular's new enter/leave animation API.

Angular Signals: set() vs update() - When to Use Each

Angular Signals: set() vs update() - When to Use Each

December 06, 2024

Choosing between set() and update() for writable signals in Angular seems trivial, but the wrong choice leads to verbose code, unnecessary complexity, or missed optimization opportunities. set() replaces the entire signal value, while update() transforms the current value using a callback function. This tutorial explains when each method is appropriate, demonstrates real-world examples, and shows how to write cleaner, more efficient signal update code.

Angular linkedSignal(): Advanced Features and Multiple Sources (v19+)

Angular linkedSignal(): Advanced Features and Multiple Sources (v19+)

November 29, 2024

Angular's linkedSignal() goes beyond simple two-way binding with advanced features that enable intelligent update logic. By comparing old and new values, you can create conditional updates, prevent unnecessary changes, and implement complex state synchronization patterns. This tutorial explores advanced linkedSignal() features including value comparison callbacks, multiple source signals, and smart update strategies that optimize performance and reduce unnecessary re-renders.

Angular Signal Queries: Replace @ContentChild with contentChild() (v19+)

Angular Signal Queries: Replace @ContentChild with contentChild() (v19+)

November 22, 2024

Content projection in Angular requires querying projected content, but the old @ContentChild and @ContentChildren decorators have limitations: they're not reactive, require lifecycle hooks, and don't integrate well with signals. The new contentChild() and contentChildren() signal queries solve these problems by providing automatic reactivity, better type safety, and seamless signal integration. This tutorial shows you how to migrate from decorator-based content queries to the modern signal query API.

Angular linkedSignal(): Create Writable Signals from Other Signals (v19+)

Angular linkedSignal(): Create Writable Signals from Other Signals (v19+)

November 15, 2024

Angular 19 introduces linkedSignal(), a powerful new primitive for creating writable signals that automatically sync with other signals. Unlike computed signals which are read-only, or effects which cause side effects, linked signals provide a clean way to create two-way reactive bindings. This tutorial demonstrates how to use linkedSignal() to simplify form state management, create reactive UI components, and avoid common anti-patterns with effects.

Angular Signal Queries: Replace @ViewChild with viewChild() (v19+)

Angular Signal Queries: Replace @ViewChild with viewChild() (v19+)

November 08, 2024

Angular's @ViewChild and @ViewChildren decorators are being replaced by signal-based query functions that offer better type safety, automatic reactivity, and cleaner code. The new viewChild() and viewChildren() functions eliminate the need for lifecycle hooks, provide reactive updates, and integrate seamlessly with Angular's signal system. This tutorial walks through converting existing decorator-based queries to the modern signal query API, showing real-world examples and migration patterns.

Angular effect(): When NOT to Use It and Better Alternatives

Angular effect(): When NOT to Use It and Better Alternatives

November 01, 2024

Angular's effect() function is often misused, leading to performance issues, unnecessary side effects, and code that's harder to reason about. While effects seem like an easy solution for reacting to signal changes, most scenarios have better alternatives using computed signals, template bindings, or lifecycle hooks. This tutorial shows you when NOT to use effects, demonstrates common anti-patterns, and provides better solutions for each scenario. You'll learn to write more efficient, maintainable Angular code.

Angular Signal Inputs: Replace @Input and ngOnChanges (v19+)

Angular Signal Inputs: Replace @Input and ngOnChanges (v19+)

October 25, 2024

Enabling and disabling form controls based on input changes requires ngOnChanges() lifecycle hooks and manual state management when using traditional @Input decorators. Signal inputs eliminate this complexity by providing reactive values that automatically trigger updates, making form state management simpler and more declarative. This tutorial demonstrates how to migrate from @Input and ngOnChanges() to signal inputs, showing how reactive forms integrate seamlessly with Angular's signal system.