Writing templates
We need to use template language to write component templates. Template language is composed of HTML along with the {}
, []
, ()
, [()]
, *
, |
, and #
tokens. Let's see what each of these is used for and how to use them.
Rendering a value
To simply render a property of the this
keyword, we need to use the {{}}
token. Inside these braces, we can simply place the property name.
We can only place expressions inside braces. The expressions we place inside them look like JavaScript. But there are a few JavaScript expressions that we are not allowed to use inside these braces. Here they are:
- Assignments (
=
,+=
,-=
) - The
new
operator - Chaining expressions with
;
or,
- Increment and decrement operators (
++
and--
) - The bitwise operators
|
and&
Pipes
We can also place pipes
in braces. A pipe is a function that accepts an input value and returns a transformed value. A pipe is represented by the |
operator. The final result of expressions inside braces can be transformed using pipes. There...