Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

Our first component

In this section, we are going to look at our first Angular component. Earlier in this chapter, we learned how to bootstrap an Angular application, and we used the AppModule. Later, we learned that the AppModule uses the AppComponent as the root component of our application. We will now look at the AppComponent:

import { Component } from "@angular/core"; 
 
@Component({ 
    selector: "app-root", 
    template: ` 
    <app-layout></app-layout>`, 
}) 
export class AppComponent { 
} 

As you can see, in Angular, a component is a class decorated with the @Component decorator. The @Component decorator takes some settings.

In this case, we use the selector setting to declare the name used to reference this component within a template. The AppComponent ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content