Title: Support spread operator (`...`) in Angular templates (e.g., for `[class]` binding) · Issue #61800 · angular/angular · GitHub
Open Graph Title: Support spread operator (`...`) in Angular templates (e.g., for `[class]` binding) · Issue #61800 · angular/angular
X Title: Support spread operator (`...`) in Angular templates (e.g., for `[class]` binding) · Issue #61800 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? core Description It would be very useful to allow the use of the JavaScript spread operator (...) within Angular templates, especially for object bindings like [cla...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? core Description It would be very useful to allow the use of the JavaScript spread operator (...) within Angular templates, ...
X Description: Which @angular/* package(s) are relevant/related to the feature request? core Description It would be very useful to allow the use of the JavaScript spread operator (...) within Angular templates, ...
Opengraph URL: https://github.com/angular/angular/issues/61800
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support spread operator (`...`) in Angular templates (e.g., for `[class]` binding)","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\ncore\n\n### Description\n\nIt would be very useful to allow the use of the JavaScript spread operator (`...`) within Angular templates, especially for object bindings like `[class]`, `[style]`\n\n**Current Behavior:**\n\nUsing the spread operator in object literals within templates results in a parser error:\n\n```\nNG5002: Parser Error: Unexpected token\n```\n\nFor example:\n\n```html\n\u003cdiv [class]=\"{ 'pt-16': nb, ...css }\">\u003c/div>\n```\n\nThis currently throws an error.\n\n**Workaround:**\n\nCurrently, we need to do the merging in the component class:\n\n```ts\nget mergedClasses() {\n return { 'pt-16': this.nb, ...this.css };\n}\n```\n\n```html\n\u003cdiv [class]=\"mergedClasses\">\u003c/div>\n```\n\nWhile this works, it adds verbosity and requires additional logic in the component when the operation could be handled declaratively in the template.\n\n### Proposed solution\n\nAllow the use of the spread operator in Angular template expressions, so the following syntax becomes valid:\n\n```html\n\u003cdiv [class]=\"{ 'pt-16': nb, ...css }\">\u003c/div>\n```\n\nThis would provide more expressive and concise template code, especially when merging static and dynamic classes or styles.\n\n\n### Alternatives considered\n\nNone","author":{"url":"https://github.com/RSamaium","@type":"Person","name":"RSamaium"},"datePublished":"2025-06-01T15:21:54Z","url":"https://github.com/angular/angular/issues/61800"}
| 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:3aff0d30-f020-2503-6ff9-703c74e86e8b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB00:229B2E:1C66F33:25667B4:6B01537F |
| html-safe-nonce | 7b2aa0782e9332d846e6df602812097d046bfae3e06ffb413dd060872778f8bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjAwOjIyOUIyRToxQzY2RjMzOjI1NjY3QjQ6NkIwMTUzN0YiLCJ2aXNpdG9yX2lkIjoiODY5MzY4MzEwNjUzNzg4NjU5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8c3aadf317d90b7c906b6fd097e7d604a0ce2936fe91fe9dc13c25e2260b83f0 |
| hovercard-subject-tag | issue:3107416609 |
| 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/61800/issue_layout |
| twitter:image | https://opengraph.githubassets.com/101fc952381c68112e8bcfcb350923971a68e60c0599811457143aac2b029d80/angular/angular/issues/61800 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/101fc952381c68112e8bcfcb350923971a68e60c0599811457143aac2b029d80/angular/angular/issues/61800 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? core Description It would be very useful to allow the use of the JavaScript spread operator (...) within Angular templates, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RSamaium |
| 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