Templates
String Interpolation
- Use double curly braces with a valid javascript expression to render data dynamically in the template
- The expression can be field, method or any other expression
- The expression will be evaluated at runtime and the value will be placed in DOM
- If value changes, angular update the dom automatically
-
{{expression}}
syntax is called string interpolation - Databinding: binding the view to a field in the component. Whenever the value changes, view will be automatically notified and updated
courses.component.html
{{ title }}
{{ getTitle() }}
{{ "Title:" + title }}
courses.component.ts
class CoursesComponent {
title = "List of Courses"
}
- Use backtick instead of single quote for multi line template