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 AllDefining Metadata with a Decorator in Angular
Learn how to define metadata with a decorator in Angular. Our comprehensive guide will teach you how to simplify your code and enhance its performance...
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.
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.
Different Types of Data Binding in Angular
Explore the various techniques of data binding in Angular - one-way, two-way, event, and interpolation binding - to optimize your app's performance.
Building High-Quality User Interfaces with Angular Material Design
Learn how to build high-quality user interfaces using Angular Material Design. Follow these best practices for consistency, responsiveness, accessibil...