-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues 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
https://github.com/th0r/ng-host-directives-cd-ref
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: host directivesstate: has PR