Angular Template

Teleport a Component in Angular (and Keep Its State)

Teleport a Component in Angular (and Keep Its State)

September 18, 2025

Moving components to different DOM locations in Angular typically destroys component state because Angular recreates views when templates change. The Angular CDK DomPortal provides a solution by moving live DOM elements without destroying component instances, preserving state, event listeners, and component lifecycle. This tutorial compares three approaches: ng-template with ngTemplateOutlet, CDK Template Portal, and CDK DomPortal, showing when each preserves state and when components get recreated.

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 ngTemplateOutlet: Eliminate Repetitive Code in Templates

Angular ngTemplateOutlet: Eliminate Repetitive Code in Templates

September 27, 2024

Code duplication in Angular templates creates maintenance nightmares, bloated bundles, and inconsistent UIs. When you need to update similar markup across multiple components, missing even one instance breaks the user experience. Angular's ng-template and ngTemplateOutlet solve this by letting you define reusable template fragments that can be stamped out anywhere in your app. This tutorial shows you how to eliminate repetitive code, create flexible components, and maintain consistency across your application.