Skip to content

fix(compiler): report error for property/event bindings on ng-content#68715

Open
toha-marko wants to merge 1 commit into
angular:mainfrom
toha-marko:fix/ng-content-binding-error
Open

fix(compiler): report error for property/event bindings on ng-content#68715
toha-marko wants to merge 1 commit into
angular:mainfrom
toha-marko:fix/ng-content-binding-error

Conversation

@toha-marko
Copy link
Copy Markdown

Previously, adding property bindings like [foo]="bar" or event bindings like (click)="handler()" to <ng-content> was silently ignored. These bindings have no effect since ng-content is not a real DOM element. This commit adds a compile-time error to warn the developer.

Fixes #24259

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Adding property/event bindings to <ng-content> is silently ignored by the compiler.

Issue Number: #24259

What is the new behavior?

The compiler now reports an error when property or event bindings are found on <ng-content>.

@pullapprove pullapprove Bot requested a review from atscott May 13, 2026 12:44
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label May 13, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 13, 2026
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 13, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Previously, adding property bindings like [foo]="bar" or event bindings
like (click)="handler()" to <ng-content> was silently ignored. These
bindings have no effect since ng-content is not a real DOM element.
This commit adds a compile-time error to warn the developer.

Fixes angular#24259
@toha-marko toha-marko force-pushed the fix/ng-content-binding-error branch from 729212e to f825e73 Compare May 13, 2026 15:51
@atscott
Copy link
Copy Markdown
Contributor

atscott commented May 13, 2026

Minimally, this would require a migration to remove those invalid properties in order to land it. Given that the bug report has no upvotes or activity in almost a decade, I have to question whether this is worth it.

@atscott
Copy link
Copy Markdown
Contributor

atscott commented May 14, 2026

Is this maybe more appropriate as a template diagnostic or eslint? Breaking compilation on something entirely innocuous seems maybe incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding property/event bindings to ng-content should error

2 participants