Repository navigation
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimebugcore: host directivesstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Angular v15 introduced hostDirectives, but currently injecting ChangeDetectorRef in them injects not the host component's cdRef (which would be logical as for me), but some strange cdRef with all the props undefined so calling its detectChanges method throws a TypeError: Cannot read properties of undefined (reading '1') because its _lView array is undefined as well.
To reproduce clone the reproduction repo, run npm i && npm start, open browser and dev tools and see the error in the console.
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
ERROR TypeError: Cannot read properties of undefined (reading '1')
at ViewRef$1.detectChanges (core.mjs:13927:38)
at eval (VM6814 some-host.directive.ts:19:15)
at timer (zone.js:2321:27)
at _ZoneDelegate.invokeTask (zone.js:370:171)
at eval (core.mjs:26142:49)
at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:26142:30)
at _ZoneDelegate.invokeTask (zone.js:370:54)
at Object.onInvokeTask (core.mjs:26451:25)
at _ZoneDelegate.invokeTask (zone.js:370:54)
at Zone.runTask (zone.js:175:37)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 15.0.1
Node: 16.17.1
Package Manager: npm 8.19.2
OS: darwin x64
Angular: 15.0.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.1
@angular-devkit/build-angular 15.0.1
@angular-devkit/core 15.0.1
@angular-devkit/schematics 15.0.1
@schematics/angular 15.0.1
rxjs 7.5.7
typescript 4.8.4
Anything else?
No response
Reacted by Toni Villena
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimebugcore: host directivesstate: has PR
Activity
pkozlowski-opensource commentedon Nov 30, 2022
Confirmed, here is a reproduction in a stckblitz: https://stackblitz.com/edit/angular-ivy-smxxdx?file=src%2Fapp%2Ftest.component.ts
cc @crisbeto
fix(core): unable to inject ChangeDetectorRef inside host directives (#…
angular-automatic-lock-bot commentedon Jan 7, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(core): unable to inject ChangeDetectorRef inside host directives (a…