Skip to the workspace
Pebellslearn by building
Introduction to Angular  ›  Lesson

How an Angular App Is Built

Angular Architecture 12 minAn Angular app is a tree of components, each a class paired with a template, supported by services for shared logic and a router that swaps which components are on screen.

angular / How an Angular App Is Built

Explore each scene at your own pace.

01 · The rule

The rule

How an Angular App Is Built

Before you write any Greenhouse code, it helps to know where each kind of code will live. Angular gives every job a named home. Once you know the homes, reading an unfamiliar Angular project becomes a matter of opening the right file.

The rule

Components draw the screen; services do the shared work; the router picks components.

Components are the building blocks you can see. Each one is a TypeScript class plus a template (its HTML) and optional styles. Components nest, so the whole app is a tree: the root component contains a plant list, which contains plant cards, which contain a water button.

Services are plain classes for work that is not about one piece of screen: fetching plants from a server, remembering the signed-in user, calculating when a plant is due for water. Angular hands a service to any component that asks, through dependency injection.

@Injectable({ providedIn: 'root' })
export class PlantService {
  private http = inject(HttpClient);
  getPlants() {
    return this.http.get<Plant[]>('/api/plants');
  }
}

The router watches the URL and decides which component fills the page: /plants shows the list, /plants/7 shows one plant.

Two helpers work inside templates:

  • Directives add behaviour to elements, like highlighting a card on hover.
  • Pipes reshape a value for display, like turning a date into 3 Mar.

Finally, Angular compiles templates into fast JavaScript ahead of time, and bootstrapApplication starts the root component inside index.html.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.