This tutorial introduces Angular step by step, from fundamentals to core concepts.
Angular is a TypeScript-based front-end framework developed by Google for building single-page web applications (SPAs).
Install Node.js first, then install Angular CLI:
npm install -g angular/cli
Create and run an Angular project:
ng new my-angular-app cd my-angular-app ng serve
Open http://localhost:4200 in your browser.
src/app – Application codeapp.component.ts – Root componentapp.component.html – Component templateapp.module.ts – Root moduleComponents control a part of the UI.
import { Component } from 'angular/core';
Component({
selector: 'app-hello',
template: 'Hello Angular
'
})
export class HelloComponent { }
< app-hello > app-hello >
export class AppComponent {
title = 'My Angular App';
}
{{ title }}
Hello {{ username }}
ngModel, import FormsModule.
Welcome User
Styled Text
Services share data and logic across components.
import { Injectable } from angular/core';
Injectable({
providedIn: 'root'
})
export class DataService {
getMessage() {
return 'Hello from Service';
}
}
constructor(private dataService: DataService) {}
message = this.dataService.getMessage();
import { RouterModule, Routes } from 'angular/router';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'about', component: AboutComponent }
];
this.form = new FormGroup({
name: new FormControl('')
});
import { HttpClient } from 'angular/common/http';
constructor(private http: HttpClient) {}
this.http.get('https://api.example.com/data')
.subscribe(data => console.log(data));
import { OnInit } from 'angular/core';
export class AppComponent implements OnInit {
ngOnInit() {
console.log('Component Initialized');
}
}
{{ today | date }}
{{ name | uppercase }}
ng build --prod
Output will be in the dist/ folder.
Angular is a powerful framework for building scalable and maintainable web applications.
Next Topics to Learn: