Full answer
The Angular CLI is the ng command. The commands you will use most:
ng new shopcreates a project with the recommended setup.ng servestarts a development server with live reload.ng generate component student-card(short formng g c student-card) creates files. Other generators:service,directive,pipe,guard,interceptor,resolver,class,interface,enum.ng buildbuilds the app. The default configuration is production, which minifies, tree-shakes, and adds hashes to file names. Useng build --configuration developmentfor an unoptimised build with source maps.ng testruns unit tests, andng e2eruns end-to-end tests if a tool is configured.ng updateupgrades Angular packages with migration scripts.ng addinstalls a package and runs its setup, for exampleng add @angular/material.ng versionandng configshow or change settings.
What ng generate component student-card creates in Angular 20: student-card.ts (the class), student-card.html, student-card.css, and student-card.spec.ts. The component is standalone, and the class is named StudentCard without the old Component suffix. Older projects (and the older CLI) create student-card.component.ts and a class named StudentCardComponent. Both are valid. Flags such as --inline-template, --inline-style, --skip-tests, and --change-detection OnPush change the output. Defaults can be set in angular.json under schematics.
Key files in a project: angular.json (build, serve, and test settings), tsconfig.json (TypeScript options), package.json, src/main.ts (bootstrap), src/app/app.config.ts (providers), src/app/app.routes.ts (routes), and src/index.html.
The CLI is also what makes upgrades predictable. ng update moves code with schematics, so read its messages and commit before running it.
// Commands:
// ng new shop
// ng generate component student-card
// ng serve
// ng test
// ng build
// file: student-card.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-student-card',
imports: [],
templateUrl: './student-card.html',
styleUrl: './student-card.css',
})
export class StudentCard {}
// file: student-card.html
<p>student-card works!</p>
// file: student-card.css
/* empty file */
// file: student-card.spec.ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StudentCard } from './student-card';
describe('StudentCard', () => {
let component: StudentCard;
let fixture: ComponentFixture<StudentCard>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StudentCard],
}).compileComponents();
fixture = TestBed.createComponent(StudentCard);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});The files below are the real output of `ng generate component student-card` in a fresh Angular 20.3 project (the `.css` file is empty). The spec was run with `ng test` in headless Chrome and passes. The commands are listed in the first comment.
Key points
- `ng new`, `serve`, `generate`, `build`, `test`, `update`, `add` cover daily work.
- `ng generate component` creates a class, template, style, and spec file.
- Angular 20 names the class without the `Component` suffix. Older code uses it. Both work.
- `angular.json` holds the build and generator settings.
Common mistakes
- Hand-writing boilerplate that the generators create with correct defaults.
- Running `ng update` with uncommitted changes, which makes the migration diff hard to read.
- Confusing `ng add` (installs and configures) with `npm install` (only installs).
Follow-ups
- What is the difference between `ng build` configurations?
- How do you change the defaults of `ng generate` for the whole project?
- What does `ng update` actually do?
Tips
- Mention that generated names changed in Angular 20, so you can read both styles.
- Say how you would use `ng update` safely: clean working tree, small steps.
- Know where the settings live (`angular.json`).
Evaluation rubric
- Lists the main commands with their purpose.
- Knows what the component generator creates.
- Understands the project's key files.