A visible button inside a panel can belong to the caller's template while an editor beside it belongs to the panel's own view. Treating both as a global DOM search makes a query appear unpredictably missing. Here you will trace those owners, remove each conditional child and repair two errors that still compile. The result is a panel that asks its current editor to focus only while it exists.
Use the checked macOS arm64/zsh workspace, Node 24.19.0, npm 12.2.1 and Angular 22.2.3 from lessons 02–04. The API stays stopped; this is synthetic local UI. Allow 40–60 minutes for prediction, interaction and repair. No new dependency is required. The query functions return signals: call the function to read its current result. General signal derivation is taught later; no effect is needed for this event-driven focus request.
Locate the declaration before choosing a query
View means elements declared in a component's own template. Content here
means elements supplied between that component's opening and closing tags by a
caller. Projection places that content at an ng-content slot; moving its
rendered location does not make it part of the receiving component's view.

Read the blue arrow as placement of a caller-declared host. The crossed path is the App query stopping at another component's template. The orange editor box belongs to DetailPanel's template and depends on its own condition. PanelAction also owns the internal button in its component template; projecting its host does not let the receiving panel query arbitrarily into that private template.
| Read location | Target | Query | Expected initial result |
|---|---|---|---|
| DetailPanel | supplied PanelAction host | contentChild(PanelAction) | instance |
| DetailPanel | its OwnedEditor host | viewChild(OwnedEditor) | instance |
| DetailPanel | supplied PanelAction host | viewChild(PanelAction) | undefined |
| App | editor inside DetailPanel's template | viewChild(OwnedEditor) | undefined |
These Angular queries use a component/directive type or a supported locator;
they are not browser CSS selectors over the whole document. A query for the
first matching child differs from a plural query's array. This exercise uses
single children. Optional queries can be undefined before a target is
available or when its condition removes it. A required query would assert
presence; it is inappropriate for this deliberately optional editor.
Apply the complete queries checkpoint
Use the current Aster component labs and Aster checkpoint tools downloads. If your older extracted packet lacks this lesson, compare the current panel's ZIP digest, extract into a new owned directory and set the paths using lesson 04's complete input procedure. Do not overwrite an older packet directory or reuse an unverified ZIP.
From your canonical $ASTER_LAB app root, stop your own app/API launches. Restore
lesson 02's local tool variables and lesson 04's checkpoint-tool/packet paths.
The known lesson 03 helper must remain present; an API descriptor must be
resolved through its identity/recovery procedure before any source switch.
Use only synthetic inputs. Keep your drafts and snapshots.
cd "$ASTER_LAB"
ASTER_LESSON=projection-and-view-queries
ASTER_VARIANT=guided
"$ASTER_NODE" "$ASTER_CHECKPOINT_TOOL" preview --root "$ASTER_LAB" \
--packet "$ASTER_COMPONENT_PACKET" --lesson "$ASTER_LESSON" --variant "$ASTER_VARIANT"
"$ASTER_NODE" "$ASTER_CHECKPOINT_TOOL" preserve --root "$ASTER_LAB" \
--packet "$ASTER_COMPONENT_PACKET" --lesson "$ASTER_LESSON" --variant "$ASTER_VARIANT"
Check the displayed root/targets; record the fresh UUID from your own preserve
output in ASTER_BACKUP. It identifies a bounded source snapshot, not a secret.
ASTER_BACKUP='<UUID from your preserve output>'
"$ASTER_NODE" "$ASTER_CHECKPOINT_TOOL" apply --root "$ASTER_LAB" \
--packet "$ASTER_COMPONENT_PACKET" --lesson "$ASTER_LESSON" --variant "$ASTER_VARIANT" \
--backup "$ASTER_BACKUP"
"$ASTER_NODE" "$ASTER_CHECKPOINT_TOOL" check --root "$ASTER_LAB" \
--packet "$ASTER_COMPONENT_PACKET" --lesson "$ASTER_LESSON" --variant "$ASTER_VARIANT"
PATH="$ASTER_NODE_HOME/bin:$PATH" "$ASTER_NODE" "$ASTER_NPM_CLI" --cache "$ASTER_CACHE" run build
Apply replaces only declared files after snapshot identity/hash checks; new source
edits require another preserve. The receipt is written last, but the file batch
is not transactional. After interruption preserve the partial state again before
reapplying. Base package/lock and personal notes outside declared targets stay;
unused older source files may remain. check identifies supplied inputs; it does
not prove their behavior or invalidate deliberately edited learner work.
The feature receipt and page identify queries-05. Launch through lesson 02's checked loopback procedure. Require Aster projection and query owners, not a still-running older page.
Read the slot, condition and query together
The complete src/app/detail-panel.ts is:
import {Component, contentChild, viewChild} from '@angular/core';
import {PanelAction} from './panel-action';
import {OwnedEditor} from './owned-editor';
@Component({selector: 'aster-detail-panel', standalone: true, imports: [OwnedEditor], template: `
<article>
<h2>Request detail panel</h2>
<div class="actions"><ng-content select="aster-panel-action" /></div>
<button type="button" (click)="toggleEditor()">Toggle owned editor</button>
@if (showEditor) { <aster-owned-editor /> }
<p>Content query: <strong data-content>{{ projectedAction() ? 'present' : 'absent' }}</strong></p>
<p>Own editor query: <strong data-editor>{{ editor() ? 'present' : 'absent' }}</strong></p>
<p>View query for projected action: <strong data-wrong-owner>{{ wrongViewAction() ? 'present' : 'absent' }}</strong></p>
<button type="button" (click)="focusEditor()">Focus owned editor</button>
<p role="status">{{ message }}</p>
</article>
`, styles: 'article {padding: 1rem; border: 1px solid #9cbeae; border-radius: .6rem; background: #f1f7f4;} button {font: inherit; padding: .55rem .8rem; margin-block: .4rem;} .actions {margin-bottom: .5rem;}'})
export class DetailPanel {
readonly projectedAction = contentChild(PanelAction);
readonly wrongViewAction = viewChild(PanelAction);
readonly editor = viewChild(OwnedEditor);
showEditor = true;
message = 'Choose an action';
toggleEditor(): void { this.showEditor = !this.showEditor; this.message = 'Editor visibility changed'; }
focusEditor(): void {
const current = this.editor();
this.message = current?.focus() ? 'Owned editor focused' : 'Owned editor unavailable';
}
}
The imports list supplies OwnedEditor to this template. PanelAction is
imported in TypeScript as the query token; App imports it into the template
that actually declares it. The slot's select matches that host type's selector.
The slot remains unconditional. App's separate @if controls whether it creates
the supplied action. Wrapping ng-content in a panel condition is not a lazy
content-creation contract; an absent-looking slot does not imply the content
was never instantiated.
DetailPanel owns showEditor, so its @if creates/removes its editor. editor()
reads the current optional result. focusEditor takes one current reference
for one click, asks it to focus and reports the returned success. A field cached
once at construction would be too early; a reference cached indefinitely would
outlive the condition. wrongViewAction deliberately exposes the wrong query
category beside the correct one, making the distinction observable.
The complete src/app/owned-editor.ts owns the actual input:
import {Component, ElementRef, viewChild} from '@angular/core';
@Component({selector: 'aster-owned-editor', standalone: true, template: `
<label for="request-note">Owned editor note</label>
<input id="request-note" #note [value]="draft" (input)="remember($event)">
`, styles: 'input {display: block; font: inherit; padding: .5rem; margin-block: .5rem; max-width: 100%;}'})
export class OwnedEditor {
private readonly note = viewChild<ElementRef<HTMLInputElement>>('note');
draft = 'Synthetic editor draft';
remember(event: Event): void {
if (event.target instanceof HTMLInputElement) this.draft = event.target.value;
}
focus(): boolean {
const input = this.note()?.nativeElement;
if (!input?.isConnected) return false;
input.focus();
return document.activeElement === input;
}
}
#note is a template reference. ElementRef<HTMLInputElement> describes the
wrapper and native element expected here. A generic type alone does not validate
an arbitrary DOM value; the template fixes this target as an input, while the
input event handler explicitly checks its event target. isConnected checks
whether the native node belongs to a document. The subsequent active-element
comparison reports whether this focus attempt actually succeeded. This local
browser work occurs on a user action, after rendering, not in an eagerly run
initializer. It is not an SSR example or a complete focus-management policy.
The child keeps its own draft string. Removing it and creating it again produces a fresh instance and the initial string. A retained JavaScript object can still exist after its Angular view is destroyed; its existence is not evidence of a connected input, resource cleanup or garbage collection.
Observe ownership through deliberate changes
Start with both children visible. Record the initial four query observations in the table. Click Projected action: the App intent count becomes 1 even though the button is displayed in the panel. Its event binding was declared by App. Click Focus owned editor: the input becomes active and the status reports Owned editor focused. Use keyboard tab/activation as well as pointer input.
Type a synthetic note, then Toggle owned editor. Expect no textbox and an absent own-editor query. Focus now reports Owned editor unavailable. Show the editor again: its value is Synthetic editor draft. This confirms creation of fresh child-local state; it does not implement persistence. Hide the projected action using App's separate button: the content query becomes absent while the editor stays present. Wait for the visible update before judging the result.
| Change | Content query | Own-editor query | What it establishes |
|---|---|---|---|
| Initial | present | present | each correct query sees its own category |
| Hide editor | present | absent | panel's condition controls that child |
| Show editor | present | present | a current query observes the new instance |
| Hide action | absent | present | caller controls projected creation |
Diagnose two compiling failures
Before each variant, stop your owned app. Set ASTER_VARIANT to the named case,
then repeat preview, preserve, apply with the new UUID, input check and build.
Do not reuse a snapshot after editing source. Both broken variants intentionally
build successfully; browser observations distinguish them from the guided case.
Task 1: visible action, absent lookup
Apply broken-content-owner. The projected action still renders and emits, but the main content indicator says absent. Repair that query without moving the button into the panel's template or using a document-wide selector.
Hint 1: find the template that declares the action host.
Hint 2: compare the panel's projectedAction initializer with wrongViewAction.
Answer and reasoning
Restore contentChild(PanelAction) for projectedAction, as in guided.
It is caller-supplied content, so a panel view query cannot establish its
presence. Keep the separate intentionally wrong query as a comparison. Verify
the main query becomes absent only when App removes the action, and that the
button still increments App's count. Rendering alone had hidden the query error.
Task 2: the status claims focus after removal
Apply broken-cached-query. Focus once, hide the editor, then focus again. Explain the incorrect focused message and repair the lifetime assumption. Keep the absent editor optional; do not make a non-null assertion conceal it.
Hint 1: inspect what the handler stores beyond one click. Hint 2: inspect whether the handler uses the child's returned boolean.
Answer and reasoning
Read this.editor() on each action and use the actual focus() result, as in
the guided handler. The broken case remembers the old instance and reports
success just because that object is truthy, ignoring the focus result. A cached
object is neither a current Angular query result nor proof of a live input.
Retest hidden focus, recreated draft and the independent projected-action
condition. This exercise establishes those observations; resource teardown and
dynamic references need their own checks in subsequent lessons.
Finish with identifiable source
Stop only your own foreground app with Ctrl+C and confirm its port is free.
Keep the base, fixture, checkpoint inputs and source snapshots for the next lesson.
On resume, recover your actual path/tool variables, inspect .aster-feature.json
and use the matching checkpoint/variant input check. Preserve modified source
before switching; do not delete a draft to make its hash match. A stale API
descriptor needs lesson 03's identity check, never a blanket process kill.
Optional generated-output cleanup follows lesson 02's guarded procedure only
after owned activity stops; the next resume then needs the locked install.
References
Component queries, content projection, viewChild API and the DOM connected-node definition support the selected Angular 22.2.3/browser behavior. The examples and diagram are original Aster teaching material; no external tutorial implementation is used.