Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@angular/common
Advanced tools
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.
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;
}
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.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 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.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.
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
License: MIT
14.0.0 (2022-06-02)
Blog post "Angular v14 is now available".
AnimationDriver.getParentElement
method has become required, so any
implementors of this interface are now required to provide an implementation
for this method. This breakage is unlikely to affect application developers,
as AnimationDriver
is not expected to be implemented in user code.Keyframes names are now prefixed with the component's "scope name". For example, the following keyframes rule in a component definition, whose "scope name" is host-my-cmp:
@keyframes foo { ... }
will become:
@keyframes host-my-cmp_foo { ... }
Any TypeScript/JavaScript code which relied on the names of keyframes rules will no longer match.
The recommended solutions in this case are to either:
None
or ShadowDom
Support for Node.js v12 has been removed as it will become EOL on 2022-04-30. Please use Node.js v14.15 or later.
TypeScript versions older than 4.6 are no longer supported.
Forms [email] input coercion
Forms [email] input value will be considered as true if it is defined with any value rather than false and 'false'.
Since Ivy, TestBed doesn't use AOT summaries. The aotSummaries
fields in TestBed APIs were present, but unused. The fields were deprecated in previous major version and in v14 those fields are removed. The aotSummaries
fields were completely unused, so you can just drop them from the TestBed APIs usage.
Forms classes accept a generic.
Forms model classes now accept a generic type parameter. Untyped versions of these classes are available to opt-out of the new, stricter behavior.
objects with a length key set to zero will no longer validate as empty.
This is technically a breaking change, since objects with a key length
and value 0
will no longer validate as empty. This is a very minor change, and any reliance on this behavior is probably a bug anyway.
Queries including + will now actually query for + instead of space. Most workarounds involving custom codecs will be unaffected. Possible server-side workarounds will need to be undone.
JSONP will throw an error when headers are set on a reques
JSONP does not support headers being set on requests. Before when a request was sent to a JSONP backend that had headers set the headers were ignored. The JSONP backend will now throw an error if it receives a request that has any headers set. Any uses of JSONP on requests with headers set will need to remove the headers to avoid the error.
This change may cause a breaking change in unit tests that are implicitly depending on a specific number and sequence of change detections in order for their assertions to pass.
This may break invalid calls to TransferState
methods.
This tightens parameter types of TransferState
usage, and is a minor breaking change which may reveal existing problematic calls.
Route.pathMatch
is now stricter. Places that use
pathMatch
will likely need to be updated to have an explicit
Route
/Routes
type so that TypeScript does not infer the type as
string
.Promise
from the
LoadChildrenCallback
, the possible type is now restricted to
Type<any>|NgModuleFactory<any>
rather than any
.initialNavigation: 'enabled'
was deprecated in v11 and is replaced by
initialNavigation: 'enabledBlocking'
.component
on ActivatedRoute
and ActivatedRouteSnapshot
includes string
. In reality, this is not the case. The component
cannot be anything other than a component class.initialUrl
is set to string|UrlTree
but in reality,
the Router
only sets it to a value that will always be UrlTree
initialUrl
is documented as "The target URL passed into the
Router#navigateByUrl()
call before navigation" but the value
actually gets set to something completely different. It's set to the
current internal UrlTree
of the Router at the time navigation
occurs.initialUrl
because it was never intended to be exposed.
Router.url
is likely the best replacement for this.
In more specific use-cases, tracking the finalUrl
between successful
navigations can also be used as a replacement.UrlTree
, the router would previously schedule
the redirect navigation within a setTimeout
. This timeout is now removed,
which can result in test failures due to incorrectly written tests.
Tests which perform navigations should ensure that all timeouts are
flushed before making assertions. Tests should ensure they are capable
of handling all redirects from the original navigation.Observables
returned by other guards: only the first value is used.FAQs
Angular - commonly needed directives and services
The npm package @angular/common receives a total of 2,732,585 weekly downloads. As such, @angular/common popularity was classified as popular.
We found that @angular/common demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.