Allow injecting ComponentRef of a component through DI

This issue has been created since 2022-09-10.

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

As of angular 14 we have the new super useful setInput on ComponentRef for dynamic components. It finally allows fully CD aware dynamic inputs changing.
Currently if I want to extend a component with a directive and set inputs from it I need to do one of the two options:

  1. Change the inputs statically in the constructor
  2. Change inputs to get/set as ngOnChanges won't fire

Proposed solution

Allowing to inject ComponentRef of the host component instead of the actual instance. This way we could just use setInput to update inputs and have a full CD aware binding support not through the template.

Alternatives considered

  1. Change the inputs statically in the constructor only - Can't apply to directive input based changes or observable based changes
  2. Change inputs to get/set - Possible but annoying and "leaks" the knowledge of this component is being used from a directive outside. How can one explain why ngOnChanges was not used...
  3. Maybe not through ComponentRef but as any other way to use setInput from DI injected components
AndrewKushnir wrote this answer on 2022-09-12

(linking #8277 here as an additional use-case)

angular-robot[bot] wrote this answer on 2022-09-13

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-10-04
Star Count 84139
Watcher Count 3064
Fork Count 22243
Issue Count 1206

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
[pdfx] iOS PdfViewPinch shows a blank page for large pages. 1 2022-04-04 2022-09-26
[BUG] - For Health permissions, read and write permissions are switched. 2 2021-02-28 2022-09-29
Unable to access Data Rods Explorer (DRE) web portal 2 2022-03-07 2022-05-16
Colorcoding for numbers in password preview 1 2021-12-16 2022-07-30
Group info 0 2021-12-14 2022-01-11
Stacktrace_unittest fails on Alpine 3.12 docker 0 2021-06-17 2022-09-26
x, y coordinates mesh section 2 2022-05-03 2022-09-16
[Bot] Broken Links Report 0 2022-06-10 2022-07-29
Shutdown all Slicer Jupyter kernels??? 3 2021-04-25 2022-09-16
IAM bindings in projects fails due to changed output of gcloud projects list command 1 2021-10-06 2022-08-01
Crash: ENOENT: no such file or directory, mkdir 'E:\Vortex Staging Folder\skyrimse\A Somewhat Faithful Lucien Replacer-48928-1-0-1619126444' 2 2022-09-08 2022-09-17
test failure due to missing command `bc` 0 2021-09-01 2022-09-15
kube-object image fail due to "v1 is forbidden: User cannot list resource" in OpenShift 4.10 cluster. 1 2022-07-01 2022-09-02
How to open multiple socket connections in single yaml to socket.io using artillery.io 0 2021-12-22 2022-07-24
"Player is accessed on the wrong thread" 3 2021-10-14 2022-09-28
Singleton make with plural ends up with bad controller 0 2022-03-25 2022-09-19
Add Surah info "بطاقات سور القرآن" 1 2022-06-19 2022-09-13
Running the demo with --alternate_corr fails 7 2021-03-08 2022-09-27
Deprecate Record interface and introduce alternative name 1 2021-02-21 2022-09-29
Why is there no transaction begin? 13 2022-08-02 2022-09-20
Auto-Join issues with Kubernetes 1 2020-10-28 2022-10-04
Search for printable strings 1 2021-08-14 2022-09-10
позарубцьовуватися -- perf 0 2022-04-20 2022-09-27
пиндючить, пиндючити - відсутні в словнику 1 2022-05-16 2022-09-27
Форми на зразок "зробим" 0 2022-04-19 2022-09-27
Add AOT infrastructure for tests 0 2021-10-20 2022-09-21
When Docker restarted,can't query anything using language chinese. 3 2022-02-24 2022-10-03
Failure to package two versions of the same chart as subcharts 0 2021-08-09 2022-09-19
opt :the execution time of multi-line sql statement is too slow 2 2021-11-03 2022-08-23
Migrating Plugfest/Events/Testing results to another structured place 0 2021-11-29 2022-09-22
502 Bad Gateway random 4 2021-01-21 2022-10-01
described behaviour of an unspecified pattern is misleading/incorrect 0 2022-09-28 2022-10-02
Error when running pypi2nix command 0 2021-08-11 2022-09-24
Whitelist not working? 13 2018-10-13 2022-09-11
crash when trying to view PR 2 2022-01-09 2022-08-30
Dialog: Responsive breakpoints no longer working 0 2022-08-25 2022-09-02
Trouble with the packaging tutorial 1 2022-09-07 2022-09-26
Postgres string filters use LIKE instead of ILIKE 1 2021-10-13 2022-09-20
Event when node name is clicked 3 2021-03-09 2022-08-04
python2.7 windows wheels failed to build for 0.19.0 5 2019-05-18 2022-09-19
Failed to load the jupyter-notebook package 13 2020-02-22 2022-09-20
读取文件的时候,ExcelReader读取隐藏的工作簿java.lang.OutOfMemoryError: Java heap space 4 2022-03-18 2022-09-23
IDXGISwapChain::Present needs PreserveSig 2 2022-06-13 2022-09-27
请问整体识别的评估指标F-score的指标从哪里看呢? 2 2022-05-11 2022-09-09
@useResult annotation doesn't count passing to a function as named argument as use 5 2022-06-10 2022-09-19
[Feature Request] Support Ray launcher on windows. 0 2022-03-11 2022-09-29
[Bug] hydra-core==1.2.0.dev1 not compatible with omegaconf==2.2.0.dev1 when using poetry 2 2022-03-12 2022-09-21
Update Images to Debian 11 1 2021-08-16 2022-09-19
Prokka needs makeblastdb 2.2 or higher... 1 2021-06-08 2022-10-02
E2E Tests - Execution context was destroyed, most likely because of a navigation. 0 2022-08-15 2022-09-07