Closed as duplicate of#7795
Closed as duplicate of#7795
Copy link
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
If I put the ng-content in both If and else then it is only considering the else one and failed to render inside if block.
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
@Component({
selector: 'app-test',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (mode() === 'selection') {
<div>Selection: <ng-content /></div>
} @else {
<div>Toggle: <ng-content /></div>
}
`,
host: {
class: 'block border border-red-500',
},
})
export class TestMode {
readonly mode = input<'selection' | 'toggle'>('selection');
}
and usage in App.ts file
import { Component } from '@angular/core';
import { TestMode } from './test.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [TestMode],
template: `
<app-test mode="selection">
<p>Hello S</p>
</app-test>
<app-test mode="toggle">
<p>Hello T</p>
</app-test>
`,
host: {
class: 'block h-screen',
},
})
export class AppComponent {}
Add it rendered as

As you can see that it is missing the Hello S
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 19.2.9
Node: 20.18.0
Package Manager: pnpm 9.12.3
OS: darwin arm64
Angular: 19.2.8
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1902.9
@angular-devkit/build-angular 19.2.9
@angular-devkit/core 19.2.9
@angular-devkit/schematics 19.2.9
@angular/cli 19.2.9
@schematics/angular 19.2.9
rxjs 7.8.2
typescript 5.7.3
zone.js 0.15.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
No labels