javascript / beginner
Snippet
Component Data Interpolation
Interpolation allows you to display dynamic data from your TypeScript class directly in your HTML template using double curly braces.
snippet.js
1
2
3
4
5
6
export class WelcomeComponent {username: string = 'John Doe';}<!-- Template --><h1>Welcome, {{ username }}!</h1>
angular
Breakdown
1
username: string = 'John Doe';
Defines a class property with a string type and an initial value.
2
{{ username }}
Angular evaluates this expression and replaces it with the property value in the view.