π °οΈ Introduction to Angular
What is Angular, CLI installation, project structure, and your first component.
What is Angular?
Angular is a platform and framework for building single-page client applications using HTML and TypeScript. It is developed and maintained by Google. Angular provides a robust, component-based architecture for building scalable web applications.
Angular vs AngularJS vs React vs Vue
Choosing the right framework depends on app scale, team expertise, and architecture requirements.
| Feature | Angular (2+) | AngularJS (1.x) | React | Vue |
|---|---|---|---|---|
| Language | TypeScript | JavaScript | JavaScript / TS | JavaScript / TS |
| Architecture | Component-Based | MVC | Component-Based | Component-Based |
| Type | Full Framework | Framework | Library | Progressive Framework |
| Data Binding | Two-way & One-way | Two-way | One-way | Two-way & One-way |
| Maintained By | Meta | Open Source Community |
Installing the Angular CLI
The Angular CLI is the official command-line tool used to create, build, serve, and test Angular applications.
npm install -g @angular/cli # Verify CLI version ng version
Creating Your First Angular App
Generate a new workspace and application using `ng new` command.
ng new my-angular-app cd my-angular-app ng serve --open
Angular Project Structure Breakdown
An Angular workspace consists of configuration files and the `src` folder containing components and assets.
| Folder / File | Purpose |
|---|---|
| src/app/ | Contains application components, modules, services, and routing. |
| src/assets/ | Stores static assets like images, fonts, and icons. |
| angular.json | CLI configuration for build, serve, and test targets. |
| package.json | Dependencies, devDependencies, and npm scripts. |
| tsconfig.json | TypeScript compiler configuration settings. |
Angular NgModule vs Standalone Components
Historically, Angular applications used NgModules (`@NgModule`) to group related features. Angular 14+ introduced Standalone Components, simplifying application structure by eliminating unnecessary module files.
import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule], template: '<h1>Welcome to {{ title }}!</h1>' }) export class AppComponent { title = 'Angular Standalone'; }