feat(core): allow reading `Injector` from a view or content query by arturovt · Pull Request #70561 · angular/angular · GitHub
Skip to content

feat(core): allow reading Injector from a view or content query - #70561

Open
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:feat/query-read-injector
Open

feat(core): allow reading Injector from a view or content query#70561
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:feat/query-read-injector

Conversation

@arturovt

@arturovt arturovt commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Queries could already read ElementRef, TemplateRef and ViewContainerRef from a matched node via the read option, but not the node injector. Getting it required a helper directive on the element.

{read: Injector} now returns the node injector of the matched element, so a component can resolve tokens as they are seen from that element. This is useful when wrapping third-party components that project templates and expect directives inside those templates to inject the host component.

Works for @ViewChild/@ContentChild and the signal-based viewChild/contentChild.

Fixes #47760

Queries could already read `ElementRef`, `TemplateRef` and
`ViewContainerRef` from a matched node via the `read` option, but not the
node injector. Getting it required a helper directive on the element.

`{read: Injector}` now returns the node injector of the matched element,
so a component can resolve tokens as they are seen from that element. This
is useful when wrapping third-party components that project templates and
expect directives inside those templates to inject the host component.

Works for `@ViewChild`/`@ContentChild` and the signal-based
`viewChild`/`contentChild`.

Fixes angular#47760
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Sep 3, 2026
@ngbot ngbot Bot added this to the Backlog milestone Sep 3, 2026
@arturovt
arturovt marked this pull request as ready for review September 4, 2026 21:41
@pullapprove
pullapprove Bot requested a review from JeanMeche September 4, 2026 21:41
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed detected: feature PR contains a feature commit labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow read Injector in ViewChild / ContentChild

2 participants