InterviewHubPRO
Section Overview
Q7

Question 7 of 283

Part 1: Architecture, Components, Directives & Lifecycle (1 - 35)

2%
Angular & Signals (283 Qs)•Part 1: Architecture, Components, Directives & Lifecycle (1 - 35)

What are components?

Components are the most basic UI building block of an Angular app, which form a tree of Angular components. These components are a subset of directives. Unlike directives, components always have a template, and only one component can be instantiated per element in a template. Let's see a simple example of Angular component

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

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

export class AppComponent {
title: string = 'Welcome to Angular world';
}