2021-11-04 16:00:13 +00:00
|
|
|
# Displaying values with interpolation
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2021-11-04 16:00:13 +00:00
|
|
|
## Prerequisites
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2021-11-04 16:00:13 +00:00
|
|
|
* [Basics of components](guide/architecture-components)
|
|
|
|
|
* [Basics of templates](guide/glossary#template)
|
|
|
|
|
* [Binding syntax](guide/binding-syntax)
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2022-05-05 22:15:16 +00:00
|
|
|
<!--todo: needs a level 2 heading for info below -->
|
|
|
|
|
|
|
|
|
|
Interpolation refers to embedding expressions into marked up text. By default, interpolation uses the double curly braces `{{` and `}}` as delimiters.
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2022-06-22 11:27:21 +00:00
|
|
|
To illustrate how interpolation works, consider an Angular component that contains a `currentCustomer` variable:
|
2020-09-02 21:11:04 +00:00
|
|
|
|
2022-05-05 22:15:16 +00:00
|
|
|
<code-example path="interpolation/src/app/app.component.ts" region="customer"></code-example>
|
|
|
|
|
|
2021-07-21 05:01:39 +00:00
|
|
|
Use interpolation to display the value of this variable in the corresponding component template:
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2022-05-05 22:15:16 +00:00
|
|
|
<code-example path="interpolation/src/app/app.component.html" region="interpolation-example1"></code-example>
|
|
|
|
|
|
2022-06-22 11:27:21 +00:00
|
|
|
Angular replaces `currentCustomer` with the string value of the corresponding component property. In this case, the value is `Maria`.
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2022-05-05 22:15:16 +00:00
|
|
|
In the following example, Angular evaluates the `title` and `itemImageUrl` properties to display some title text and an image.
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2022-05-05 22:15:16 +00:00
|
|
|
<code-example path="interpolation/src/app/app.component.html" region="component-property"></code-example>
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2021-11-04 16:00:13 +00:00
|
|
|
## What's Next
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2021-11-04 16:00:13 +00:00
|
|
|
* [Property binding](guide/property-binding)
|
|
|
|
|
* [Event binding](guide/event-binding)
|
2020-04-28 20:26:58 +00:00
|
|
|
|
2023-09-01 20:39:54 +00:00
|
|
|
@reviewed 2023-09-01
|