Title: OnPush + ViewContainerRef.createComponent() + ng-container breaks · Issue #53731 · angular/angular · GitHub
Open Graph Title: OnPush + ViewContainerRef.createComponent() + ng-container breaks · Issue #53731 · angular/angular
X Title: OnPush + ViewContainerRef.createComponent() + ng-container breaks · Issue #53731 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Hi. This code will not render component: host-cmp.ts: import { ChangeDetectionStrategy, ViewContainerRef, Component, ViewChild, AfterViewIn...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Hi. This code will not render component: host-cmp.ts: import { ChangeDetectionStrategy, ViewContain...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Hi. This code will not render component: host-cmp.ts: import { ChangeDetectionStrategy, ViewContain...
Opengraph URL: https://github.com/angular/angular/issues/53731
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OnPush + ViewContainerRef.createComponent() + ng-container breaks","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncore\n\n### Is this a regression?\n\nYes\n\n### Description\n\nHi. This code will not render component:\r\n\r\nhost-cmp.ts:\r\n\r\n```\r\nimport {\r\n ChangeDetectionStrategy,\r\n ViewContainerRef,\r\n Component,\r\n ViewChild,\r\n AfterViewInit,\r\n} from '@angular/core';\r\nimport { TestCmp } from './test-cmp';\r\n\r\n@Component({\r\n selector: 'host-cmp',\r\n template: '\u003cng-container #testForVcr />',\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush, // THIS breaks\r\n})\r\nexport class HostCmp implements AfterViewInit {\r\n @ViewChild('testForVcr', { read: ViewContainerRef })\r\n private readonly vcr!: ViewContainerRef;\r\n\r\n ngAfterViewInit(): void {\r\n this.vcr.createComponent(TestCmp);\r\n }\r\n}\r\n```\r\n\r\nchild-cmp.ts:\r\n\r\n```\r\nimport {\r\n ChangeDetectionStrategy,\r\n Component,\r\n OnInit,\r\n signal,\r\n} from '@angular/core';\r\n\r\n@Component({\r\n selector: 'test-cmp',\r\n template: 'hi from test cmp: {{ testSig() }}',\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class TestCmp implements OnInit {\r\n public readonly testSig = signal\u003c'123' | '456'>('456');\r\n\r\n constructor() {\r\n console.log('test cmp construct');\r\n }\r\n\r\n ngOnInit(): void {\r\n this.testSig.set('123');\r\n console.log('test cmp init');\r\n }\r\n}\r\n```\r\n\r\n`ngOnInit` doesn't get called also, while constructor() calls.\r\nIf i remove OnPush from parent-cmp everything works as expected\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://stackblitz.com/edit/stackblitz-starters-zvdbww?file=src%2Ftest-cmp.ts\n\n### Please provide the exception or error you saw\n\n_No response_\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nlatest\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/zip-fa","@type":"Person","name":"zip-fa"},"datePublished":"2023-12-31T11:44:56Z","url":"https://github.com/angular/angular/issues/53731"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b96c3b02-cfd2-da94-5d51-2f8d12610dd2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B286:134361:193BB80:212E2E5:6B0140C4 |
| html-safe-nonce | 617bc5a14e3ea1bff5be82f3178550983fdad922d9c922d1a49e011bcec996a4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjg2OjEzNDM2MToxOTNCQjgwOjIxMkUyRTU6NkIwMTQwQzQiLCJ2aXNpdG9yX2lkIjoiNDI2NjUwNzQ0NDMzMjYwOTczMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 99e72b7318c6d78c2dd2b47dbac399b74456cd115123b0f7165ebfda29580115 |
| hovercard-subject-tag | issue:2061033364 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/53731/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d20e4e74611ed3e2c4e54196249f37e9776eeeaeed45aa2bfed35525d462780/angular/angular/issues/53731 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d20e4e74611ed3e2c4e54196249f37e9776eeeaeed45aa2bfed35525d462780/angular/angular/issues/53731 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description Hi. This code will not render component: host-cmp.ts: import { ChangeDetectionStrategy, ViewContain... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zip-fa |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width