Angular 2 – Templates

What is Templates in angular 2?

In the previous chapter on Components, we have already cover some part template.

This is the view section of our component that holds our template. Template can consists of HTML TAGs and other component as well. It allows us to tie logic from our component directly to a view. When defining a template, we can either write it inline template , or we can also use templateUrl to link to an external template.

We personally recommended you to use external template to keep you code simple and maintanabe.

There are two ways of defining temples in components

1. Inline Template:

2. Using External template file.

In this way we create an separate external HTML file for our component template and pass this file in templateUrl meta decorator.