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

14 REASONS TO USE ANGULAR FOR WEB DEVELOPMENT


Angular is one of the most popular JavaScript-based frontend frameworks in the world and also very popular here on GitHub.

Full Angular 13 Firebase Authentication Tutorial Example


We&amp;#039;ll show you how to create an Angular Firebase authentication system from the ground up with the Firebase Real-time NoSQL cloud database.

Angular 13 Directives – Component, Structural & Attribute


Angular Directives tutorial, Directives in Angular is basically a TypeScript class. such as Component, Structural &amp;amp;amp; Attribute.

What is an Angular Module?


Learn what an Angular module is, its purpose, and how to create and use them in your Angular applications. Get started with this comprehensive guide.

What is the difference between component and directive in Angular?


Learn the difference between Angular's components and directives. Discover their unique features and how to use them to build powerful web application...