What is @angular/common?
The @angular/common package is a core Angular library that provides commonly needed services, pipes, and directives that are essential for application development. It is part of the Angular framework and is used for tasks such as HTTP communication, localization, and various utility functions.
What are @angular/common's main functionalities?
HTTP Client
Provides a simplified API for HTTP functionality which allows performing HTTP requests and handling responses within an Angular application.
import { HttpClientModule } from '@angular/common/http';
@NgModule({
imports: [
HttpClientModule
]
})
export class AppModule { }
Common Directives
Includes directives like ngIf, ngFor, and ngSwitch which are essential for controlling the rendering of the template.
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
]
})
export class SharedModule { }
Location Services
Provides services for interacting with the browser's URL. Useful for routing and navigation within an Angular application.
import { Location } from '@angular/common';
@Component({
selector: 'app-component',
template: '<p>Current path: {{ location.path() }}</p>'
})
export class AppComponent {
constructor(public location: Location) { }
}
Date, Currency, and Decimal Pipes
Provides built-in pipes for formatting data such as dates, currency, and numbers.
import { DatePipe, CurrencyPipe, DecimalPipe } from '@angular/common';
@Component({
selector: 'app-component',
template: '<p>Today is {{ today | date }}</p><p>Amount: {{ amount | currency }}</p>'
})
export class AppComponent {
today = new Date();
amount = 1234.56;
}
Other packages similar to @angular/common
react
React is a JavaScript library for building user interfaces. While it is not a one-to-one comparison with @angular/common, React provides a component-based architecture similar to Angular's directives and services.
vue
Vue.js is a progressive JavaScript framework used for building UIs and single-page applications. It offers similar directives and reactivity systems but is generally considered to be more lightweight and easier to integrate into projects than Angular.
axios
Axios is a promise-based HTTP client for the browser and Node.js. It provides many of the same HTTP client capabilities as the HttpClientModule in @angular/common.
moment
Moment.js is a library for parsing, validating, manipulating, and formatting dates. It is similar to the DatePipe in @angular/common but is a standalone library focused solely on date manipulation.
17.0.7 (2023-12-13)
compiler
| Commit | Type | Description |
| -- | -- | -- |
| 4fd5409090 | fix | handle ambient types in input transform function (#51474) |
compiler-cli
| Commit | Type | Description |
| -- | -- | -- |
| a603338fe8 | fix | generate less type checking code in for loops (#53515) |
core
| Commit | Type | Description |
| -- | -- | -- |
| 58ed76be93 | fix | Avoid refreshing a host view twice when using transplanted views (#53021) |
| c16b5e8290 | fix | Multiple subscribers to ApplicationRef.isStable should all see values (#53541) |
| 17dbf8b8e2 | fix | remove signal equality check short-circuit (#53446) |
| 5b4add27b6 | fix | update feature usage marker (#53542) |
| 68d111c841 | perf | avoid changes Observable creation on QueryList (#53498) |
| 044cb553b4 | perf | optimize memory allocation when reconcilling lists (#52245) |
migrations
| Commit | Type | Description |
| -- | -- | -- |
| 96ab999698 | fix | CF Migration - ensure bound ngIfElse cases ignore line breaks (#53435) |
| c9a1c6f1c7 | fix | cf migration - undo changes when html fails to parse post migration (#53530) |
| b75aca1d74 | fix | CF migration only remove newlines of changed template content (#53508) |
| e88a12d5b3 | fix | cf migration validate structure of ngswitch before migrating (#53530) |
| 543df3dca5 | fix | ensure we do not overwrite prior template replacements in migration (#53393) |
| d232ea143f | fix | fix cf migration import removal when errors occur (#53502) |
platform-browser
| Commit | Type | Description |
| -- | -- | -- |
| d5c631bf36 | fix | Get correct base path when using "." as base href when serving from the file:// protocol. (#53547) |
router
| Commit | Type | Description |
| -- | -- | -- |
| e750e4edcf | fix | provide more actionable error message when route is not matched in production mode (#53523) |
<!-- CHANGELOG SPLIT MARKER -->
<a name="17.0.6"></a>