@Component

noun

say it: “kum-POH-nent” /kəmˈpoʊnənt/

The Angular decorator that turns a class into a component, naming its selector, template and imports.

What does @Component do in Angular?

@Component — The decorator that turns a TypeScript class into an Angular component. It names the component's selector (its HTML tag), its template, its styles, and the imports the template uses.

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

@Component({
  selector: 'app-price-tag',
  template: `<p>{{ price }}</p>`,
})
export class PriceTag {
  protected readonly price = 18;
}

In a sentence

  • “The @Component decorator gives PriceTag its selector, app-price-tag.”

Level: Novice · More Angular terms at this level

Updated