Before we jump into how, let's talk about why.
Using templates is aligned with the rule of least power, which is a useful design principle.
the less powerful the language, the more you can do with the data stored in that language. [...] I chose HTML not to be a programming language because I wanted different programs to do different things with it: present it differently, extract tables of contents, index it, and so on.
–Tim Berners-Lee, on the Principle of Least Power
For the full article refer https://www.w3.org/DesignIssues/Principles.html#PLP
Because templates are pure HTML, and hence are constrained, tools and developers can make smart assumptions about what components are and how they behave, and Angular can do a lot of interesting things that would have not been possible if components used JavaScript instead. Let's...