Use Complex Expressions to Compute Values
Template expressions support a wide range of computations within a component template. Use template expressions to reduce or eliminate the need for display-only properties or getters.
Do not use complex template expressions in production. See Considerations and Limitations for additional cautions.
With simple property binding, dynamically computing a value for a property used in a template requires you to:
- Define a getter that computes the value in the component class, and then
- Reference that getter in the template.
Template expressions are more powerful than basic property binding. They can contain any JavaScript expression that is valid in a template context. Additionally, complex expressions can be used for inline computations, which reduces the need for getters that solely compute or format values for a component’s user interface.
Template expressions are more powerful than basic property binding. They can contain any JavaScript expression that is legal in a template context. Complex expressions can be used for inline computations, which reduces the need for getters that solely compute or format values for a component’s user interface.
The following example illustrates a range of template expressions used to display user and status information. Additional examples covering specific syntax and use cases are offered throughout the documentation.