It's unlikely that you're going to get this syntax to work in a template (there are many valid typescript constructs that don't work in templates).

You could write a helper method in the component instead, that takes the item as an argument, and then makes the appropriate call, as in, for example:

public doCommand(item: ToolbarItem): void {
  item.command(...item.commandParams);
}

and then change your template to:

<button (click)="doCommand(item)"...
Answer from GreyBeardedGeek on Stack Overflow
🌐
GitHub
github.com › angular › angular › issues › 61800
Support spread operator (`...`) in Angular templates (e.g., for `[class]` binding) · Issue #61800 · angular/angular
June 1, 2025 - You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. ... There was an error while loading. Please reload this page. ... area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercore: basic template syntaxstate: has PR ... It would be very useful to allow the use of the JavaScript spread operator (...) within Angular templates, especially for object bindings like [class], [style]
Author   angular
Discussions

Angular-How to use spread operator in angular html template
I have a simple angular app with a module and a component. For the sake of simplicity let us assume that the component ts and the template file is like the following snippet import { Compon... More on stackoverflow.com
🌐 stackoverflow.com
typescript - Can you use spread operator in the template in angular - Stack Overflow
Can you use spread operator in the template in angular? I have seen this question and answer. The accepted answer says it is impossible to do so: It's unlikely that you're going to get this synt... More on stackoverflow.com
🌐 stackoverflow.com
angular - RxJS : how to understand the spread operator here? - Stack Overflow
Now you have another object (in another memory location) with the same content as product. Now we create a new object with other values with the spread operator: More on stackoverflow.com
🌐 stackoverflow.com
August 13, 2022
difference between spread operator and without the spread in angular
I just have a question about a piece of code that can be done with the spread operator (...) and without the spread operator. But the result stays the same. exercisesChanged = new Subject More on stackoverflow.com
🌐 stackoverflow.com
🌐
C# Corner
c-sharpcorner.com › blogs › spread-and-rest-operators-in-angular
Spread and Rest Operators in Angular
July 29, 2024 - The spread operator (...) expands elements of arrays or objects, useful for combining data. The rest operator (...) collects multiple elements into an array, aiding in parameter handling and destructuring.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Spread_syntax
Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
May 22, 2026 - The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value ...
🌐
YouTube
youtube.com › shorts › Pc51dDsWd7Q
What is Spread Operator in Angular? | Simplifying Code with Angular - YouTube
In this short tutorial, we'll explore the Spread Operator (...) in Angular, a powerful tool for managing arrays and objects efficiently. Learn how to combine...
Published   November 15, 2024
Views   711
🌐
w3tutorials
w3tutorials.net › blog › how-to-use-spread-operator-in-angular-component-template
How to Use the Spread Operator in Angular Component Templates to Pass Arrays to Functions — w3tutorials.net
The spread operator is a versatile tool that simplifies passing array elements to functions in Angular templates. By using ...array, you can avoid manual indexing, handle dynamic argument lists, and write cleaner, more maintainable templates.
🌐
CodeSandbox
codesandbox.io › s › spread-operator-in-angular-5hvpyk
Spread Operator in Angular - CodeSandbox
January 15, 2023 - Spread Operator in Angular by mr.viral.coder using @angular/animations, @angular/common, @angular/compiler, @angular/core, @angular/forms, @angular/platform-browser, @angular/platform-browser-dynamic, @angular/router, bootstrap
Published   Jan 13, 2023
Author   mr.viral.coder
Find elsewhere
🌐
Briantree
briantree.se › home › angular › angular 21.1: compose arrays and objects directly in templates
Angular 21.1: Compose Arrays and Objects Directly in Templates | Brian Treese
January 22, 2026 - This update lets you compose arrays and objects directly in templates using the spread operator (...). This means you can merge arrays and extend objects declaratively and keep UI logic where it belongs: in the template.
🌐
YouTube
youtube.com › watch
💥 The Typescript Object Spread Operator - YouTube
This video is part of the Typescript: The Ultimate Bootcamp Course - https://angular-university.io/course/typescript-bootcampCheck out the PDF E-Books avail...
Published   June 22, 2022
🌐
YouTube
youtube.com › code with z
Mastering the Spread Operator for Arrays & Objects in JS | Part 9 | JavaScript for React & Angular - YouTube
Unlock the full potential of the Spread Operator in JavaScript with our in-depth tutorial! 🌟 The Spread Operator is a powerful tool that simplifies working ...
Published   May 27, 2024
Views   107
🌐
YouTube
youtube.com › watch
Angular 21.1 New feature: spread operator in templates
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Top answer
1 of 3
1

From what I understand the spread operator works both to add new keys to an object and to overwrite the keys it already has.

I imagine a product object like this:

product = {
  price: 0,
  category: a
};

Now we copy the object with the spread operator:

const product2 = {...product};

Now you have another object (in another memory location) with the same content as product.

Now we create a new object with other values with the spread operator:

const produc3 = { ...product, price: 1, category: b };

Now you have an object that has the same keys as the original but with other values.

Now we add a new key to the object:

const product4 =  { ...product, name: 'car'};

Now you have an object that has the same keys as the original object, plus the name key.

You will never have an object with 2 keys the same.

Tested in the chrome console, if you try to define an object with two equal keys only the last key of the definition prevails.

2 of 3
1

It is a JavaScript feature not RxJS specific per say. I think this snippet of code (or similar) is part of RxJS examples slides of Deborah Kurata conference or something like this. If you are interested, there is a record on youtube on a similar usage of this syntax with RxJS by Deborah Kurata. As mentioned on MDN:

Spread syntax can be used when all elements from an object or array need to be included in a new array or object, or should be applied one-by-one in a function call's arguments list. There are three distinct places that accept the spread syntax:

Function arguments list (myFunction(a, ...iterableObj, b))

Array literals ([1, ...iterableObj, '4', 'five', 6])

Object literals ({ ...obj, key: 'value' })

In our case above it is called shallow cloning with Object literals. Read more here

Top answer
1 of 1
2

I will explain everything to you: Spread operator will copy all of your object {keys,values} (except some advanced types like symboles) and assign it to a new variable (means a new reference or lets say a new memory address reference).
To more clarification: Of course there is a big difference between using spread and without spread operator i will give you an example:

lets say: this.availableExercises has a memory address of 0xAABBCCDD so:
this.exercisesChanged.next(this.availableExercises); ==> this line will pass the 0xAABBCCDD address to the .next(..) method to be handled after by some codes.
but if we use spread operator like:

this.exercisesChanged.next({...this.availableExercises}); ==> this will generate a copy of the {keys,values} means a new object of your previous 0xAABBCCDD addressed object, and assign it to a new reference (new memory address) like 0x99FF1155.
To understand what i meant look at this example:

let myOldReference = this.availableExercises; // memory address: 0xAABBCCDD 
this.exercisesChanged.next(myOldReference); // .next(0xAABBCCDD);

let myNewReference = {...this.availableExercises}; // this will generate a copy to a new memory address: 0x99FF115
this.exercisesChanged.next(myNewReference ); // .next(0x99FF115);

so that myOldRefernce !== myNewReference because 0xAABBCCDD is different to 0x99FF115 as references. But keep in mind, this will keep the same {keys, values} because it's a copy of keys values, but with different memory references.

That's why you see the same keys,values, but in backgroud, it's different references.

🌐
X
x.com › angular › status › 2014382553868669322
Angular - ️ Object literals
January 22, 2026 - Spread syntax in templates [...] You can now use the spread/rest operator (...) inside Angular templates. This works in the following scenarios: ▶️ Object literals: {a: 1, ...foo} ▶️ Array literals: [1, ...foo] ▶️ Function calls: fn(1, ...foo) Angular handles this efficiently https://t.co/8pK3W3MtD1
🌐
W3Schools
w3schools.com › react › react_es6_spread.asp
React ES6 Spread Operator
React Compiler React Quiz React Exercises React Syllabus React Study Plan React Server React Interview Prep React Bootcamp ... The JavaScript spread operator (...) copies all or part of an existing array or object into another array or object.