Angular — CLI
Common Commands
| Command | Description |
|---|---|
| ng new | Create new project |
| ng serve | Start dev server |
| ng build | Build for production |
| ng generate | Generate files |
| ng test | Run unit tests |
| ng e2e | Run e2e tests |
| ng lint | Lint project |
Generate Commands
# Components
ng generate component header
ng g c header
# Services
ng generate service services/user
ng g s services/user
# Modules
ng generate module admin
ng g m admin
# Pipes
ng generate pipe pipes/date
ng g p pipes/date
# Directives
ng generate directive directives/highlight
ng g d directives/highlight
Build Options
# Development
ng build
# Production
ng build --configuration production
# Watch mode
ng build --watch
Serve Options
# Default port
ng serve
# Custom port
ng serve --port 8080
# Open browser
ng serve --open
# SSL
ng serve --ssl
Mini Practice
- Generate components
- Generate services
- Build for production
- Configure serve options
Up Next
Continue with Project Structure — understanding the project.
Related Topics
Frequently Asked Questions about CLI
What is CLI in Angular?
CLI is a fundamental concept in Angular. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn CLI?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn CLI.
Why is CLI important in Angular?
CLI is essential for Angular development. Understanding this concept will help you write better code and solve real-world problems more effectively.