Working with Angular component template

Sang
Written by Sang on
Working with Angular component template

Instead of using an external template file, we can also use an inline template which means you define the HTMLcode in the Typescript code.

We can do this by simply going to our component change templateUrl to template.

Angular template code

Either linked to an external template or just the template to define it in component’s typescript file, one of two has to be present. Each component needs to have a template, this is the one property you have to have at all times.

Now we can write our template code in Typescript file.

Angular template code

If you want to write multi-line strings, which you probably want if you add more HTML code to it, you can switch from a normal string with single quotation marks to using back ticks by Javascript template expressions, to be able to write multi-line strings.

Angular template code