By connecting controls to Angular component properties, you may display data in a template, which is an HTML view. The template for your component can be kept in one of two locations. The @Component decorator's templateUrl property allows you to declare the template either inline using the template property or in a separate HTML file and link to it in the component metadata.

Using inline template with template syntax,

import { Component } from '@angular/core';

@Component ({
   selector: 'my-app',
   template: '
      <div>
         <h1>{{title}}</h1>
         <div>Learn Angular</div>
      </div>
   '
})

export class AppComponent {
   title: string = 'Hello World';
}

Using separate template file such as app.component.html

import { Component } from '@angular/core';

@Component ({
   selector: 'my-app',
   templateUrl: 'app/app.component.html'
})

export class AppComponent {
   title: string = 'Hello World';
}

I hope you will like the content and that it will help you to learn?What is template??If you like this content, do share it.


Recommended Posts

View All

Angular 13 Firebase - Create a user with an Email address and Password


We&amp;#039;ll show you how to use the Firebase database to create a user with an email and password in the Angular 13 frontend framework.

Angular 13 Data Binding Example Tutorial


The concept of data binding will be discussed. You&amp;#039;ll also find out how to bind data in an Angular web application

Angular 13 Firebase Send Mail Example


Learn how to send a verification email to a new user in Angular, as well as how to prohibit users from accessing their accounts until the email has be...

Angular 13 NgModule Tutorial with Example


NgModule is an Angular decorator that organises your single-page Angular application&amp;#039;s services, pipelines, directives, and components.

What are the key components of Angular?


Angular is a powerful JavaScript framework for building web applications. Discover its key components and how they work together in this guide.