Reader small image

You're reading from  Expert Angular

Product typeBook
Published inJul 2017
Reading LevelExpert
PublisherPackt
ISBN-139781785880230
Edition1st Edition
Languages
Right arrow
Author (1)
Sridhar Rao Chivukula
Sridhar Rao Chivukula
author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula

Right arrow

Learning about Template Syntax

The components view is defined using a template, which tells Angular how to render the look. Inside the template, we define how the data should appear and also attach events using Data Binding.

Most HTML tags can be used inside the Angular template. We can use and define user-defined custom directives.

The general syntax of defining a template for a component is as follows:

import {Component, View} from "@angular/core";

@Component({
selector: 'my-app',
template: `<h2>{{ title }}</h2>`
}) export class MyTemplateComponent {
title = 'Learning Angular!!!'
}

Let's analyze the preceding code snippet in detail:

  1. We defined a component, MyTemplateComponent.
  2. We defined the component view with template.
  3. Inside the template, we defined a <h2> tag.
  4. We defined a title variable and assigned a value.
  5. Using the...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Expert Angular
Published in: Jul 2017Publisher: PacktISBN-13: 9781785880230

Author (1)

author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula