From 20fa87dc249bdae9a2bf18f94271e41997bf9193 Mon Sep 17 00:00:00 2001 From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com> Date: Thu, 17 Sep 2026 14:03:25 -0500 Subject: [PATCH] docs: clarify boundary content projection limitation (cherry picked from commit 1a32087b4d3bf6ec219f7b6fac83b6c32af4822c) --- .../guide/templates/error-boundaries.md | 26 +++++++++++++++++++ tools/manual_api_docs/blocks/boundary.md | 2 ++ 2 files changed, 28 insertions(+) diff --git a/adev/src/content/guide/templates/error-boundaries.md b/adev/src/content/guide/templates/error-boundaries.md index a3466aff366..de0331239ba 100644 --- a/adev/src/content/guide/templates/error-boundaries.md +++ b/adev/src/content/guide/templates/error-boundaries.md @@ -18,6 +18,32 @@ The `@boundary` block wraps a section of your template. If any component or dire } ``` +## Content projection + +If your component uses [content projection](guide/components/content-projection), wrapping `` in a `@boundary` does not catch errors from projected content. That content belongs to the view that declares it, not the receiving component's view. + +For example, a wrapper component with the following template does not catch errors from components projected into it: + +```angular-html +@boundary { + +} @error { +

Something went wrong!

+} +``` + +To catch those errors, wrap the wrapper component and its projected content in a `@boundary` in the parent template: + +```angular-html +@boundary { + + + +} @error { +

Something went wrong!

+} +``` + ## Accessing the error object You can access the caught error by accessing the implicit `$error` variable: diff --git a/tools/manual_api_docs/blocks/boundary.md b/tools/manual_api_docs/blocks/boundary.md index 9add56ebc54..a41315092c3 100644 --- a/tools/manual_api_docs/blocks/boundary.md +++ b/tools/manual_api_docs/blocks/boundary.md @@ -16,6 +16,8 @@ The `@boundary` block is a control flow mechanism that lets you intercept and ha The `@boundary` block encapsulates its content and catches any errors that occur during the initial render or subsequent change detection cycles of its child views. If an error is caught, the framework stops rendering the main view and instead renders the fallback UI provided in the `@error` block. +IMPORTANT: Wrapping `` in a `@boundary` does not catch errors from projected content. See [Content projection with error boundaries](guide/templates/error-boundaries#content-projection). + You can capture the error object by declaring a variable in the `@error` block, for example `@error (let err)`. You can use multiple `@error` blocks with `when` clauses to conditionally render different fallbacks based on the error type, with a final fallback `@error` block at the end. You can also access a `$reset` function to attempt re-rendering the boundary content.