Workspace structure
When you create a new Angular workspace withng new, the CLI generates the following structure:
Root configuration files
The workspace root contains essential configuration files for your project.angular.json
The workspace configuration file defines build, serve, and test configurations:angular.json
projects: Contains configuration for each application or libraryarchitect: Defines builders for different tasks (build, serve, test)options: Specifies paths, assets, styles, and build settings
package.json
The npm configuration file lists dependencies and scripts:package.json
scripts: Convenient commands to run CLI commandsdependencies: Runtime packages required by your applicationdevDependencies: Development tools and build packages
Use
npm start as a shortcut for ng serve to start the development server.TypeScript configuration files
Angular uses multiple TypeScript configuration files for different contexts.tsconfig.json
The base TypeScript configuration:tsconfig.json
experimentalDecorators: Enables decorators like@Componentmodule: Specifies module system (ES2022)target: JavaScript version for output (ES2022)strictTemplates: Enables strict type checking in templates
tsconfig.app.json
Extends base configuration for application builds:tsconfig.app.json
tsconfig.spec.json
Configuration for test files:tsconfig.spec.json
Other root files
.editorconfig
Defines consistent coding styles across different editors:.editorconfig
.gitignore
Specifies files and directories Git should ignore:.gitignore
Source directory (src/)
Thesrc/ directory contains your application code and assets.
src/index.html
The main HTML page that hosts your Angular application:src/index.html
<app-root> element is where Angular inserts your application.
src/main.ts
The application entry point that bootstraps the Angular application:src/main.ts
- Imports the platform browser module
- Imports the root application module
- Bootstraps the application to run in the browser
src/styles.css
Global styles applied across your entire application:src/styles.css
src/assets/
Directory for static assets like images, fonts, and files:App directory (src/app/)
The application source code lives in thesrc/app/ directory.
Component files
Each component typically consists of four files:app.component.ts
The component class containing logic:src/app/app.component.ts
app.component.html
The component template:src/app/app.component.html
app.component.css
Component-specific styles:src/app/app.component.css
app.component.spec.ts
Unit tests for the component:src/app/app.component.spec.ts
app.module.ts
The root module that defines the application structure:src/app/app.module.ts
Build and output directories
dist/
Generated byng build, contains compiled application ready for deployment:
.angular/
Cache directory created by the Angular CLI to speed up builds:Multi-project workspaces
Workspaces can contain multiple projects (applications and libraries):Next steps
Now that you understand the project structure, explore Angular’s core concepts.Components
Build reusable UI components
Templates
Create dynamic HTML templates
Services
Share data and logic across components
Routing
Navigate between different views
