Components

Components are the main building block for Angular applications. Each component consists of:

  • An HTML template that declares what renders on the page
  • A TypeScript class that defines behavior
  • A CSS selector that defines how the component is used in a template
  • Optionally, CSS styles applied to the template

It allows you to split up the whole application into reusable components. They display data on the screen, listen for user input, and take action based on that input.

Creating a new component

ng generate component NAME
ng g c NAME
ng g c NAME --skipTests true

Each component needs to have a template.

We can put interfaces in separate folder:

src/app/models
interface
Was this page helpful?