AI Hints
Home›Angular Tutorial›What You Need, Creating a Project and The Project Structure
Angular · Lesson 6 of 120

The Project Structure

A tour of the files.

⏱ 2 min read▶ Video at 6:10🎓 Free
Watch this lesson in the Angular courseWatch on YouTube ↗Full Angular course

A new project has quite a few files. The good news is, we'll work almost entirely in one folder, source app.

  • Quite a few files
  • Most are settings
  • We work in src/app

The important files

Package dot json lists the packages, and scripts. Angular dot json holds the CLI settings. The source folder holds our code. Index dot html is the one page. Main dot ts starts the app. And the app folder holds our components.

FileHolds
package.jsonpackages and scripts
angular.jsonCLI settings
src/index.htmlthe one HTML page
src/main.tsstarts the app
src/app/our components

src/index.html

This is the only HTML page in the whole app. Base href tells the router where the app lives. And app root is a custom tag. Angular puts our root component right there.

index.htmlhtml
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Shop</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
</body>
</html>

src/main.ts

Main dot ts runs first. It imports the app configuration, and the root component, called App. Then bootstrap application starts Angular, with that component. If something goes wrong, the error is logged.

app.tstypescript
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { App } from './app/app';

bootstrapApplication(App, appConfig)
  .catch((err) => console.error(err));

Summary

Index dot html is the one page, main dot ts starts the app, and our components live in source app. Next, the root component.

Key takeaways
  • index.html
  • main.ts
  • src/app/
Next up: The Root Component — where it all starts