A hands-on Angular 19 project to learn Reactive Forms from basics to advanced use-cases, plus a full Reactive CRUD example backed by json-server.
This repo is structured as small, focused demo components. Each card in the UI demonstrates one concept:
FormControlbasicsFormGroupbasics- Form submit flow (
ngSubmit) - Built-in validators
- Nested
FormGroup FormArraydynamic controls- Custom validator
- Async validator
- Strongly typed reactive forms
valueChangesstream- Conditional validation
- Full Reactive CRUD with API integration
- Angular
19.2.x - Reactive Forms (
@angular/forms) - HttpClient (
@angular/common/http) json-serverfor local mock REST API
- App shell:
src/app/app.component.htmlsrc/app/app.component.scss
- Reactive form demos:
src/app/components/*
- Reactive CRUD demo:
src/app/components/understanding-reactive-crud/
- Local API seed data:
db.json
- Node.js
18+(recommended) - npm
npm installnpm startOpen: http://localhost:4200/
npm run apiAPI base URL:
http://localhost:3000
Users endpoint used by CRUD component:
http://localhost:3000/users
Use two terminals:
Terminal 1:
npm run apiTerminal 2:
npm startnpm start- Angular dev servernpm run build- Production buildnpm run watch- Build in watch modenpm test- Unit testsnpm run api- Startjson-serveron port3000
In understanding-reactive-crud:
- Form is defined using
FormGroupand typedFormControls. - Validation is done with built-in validators (
required,email,minLength). createUsersendsPOST /users.loadUserssendsGET /users.editUserpatches selected row into the form.updateUsersendsPUT /users/:id.deleteUsersendsDELETE /users/:id.- UI exposes loading, success, and error states.
- Start from component 1 and move in order.
- Watch each card's JSON debug block to understand control/form state (
touched,dirty,valid,errors). - In conditional and async validation demos, change one input at a time and observe status changes.
- For
FormArray, add/remove controls and inspect output shape.
- If CRUD shows API connection errors:
- ensure
npm run apiis running - check port
3000is free - confirm
db.jsonexists at project root
- ensure
- If Angular app does not load:
- run
npm install - run
npm start
- run
npm run buildBuild output:
dist/repro.understanding.angular.reactive.forms
