Let’s take a look under the hood of the component decorator mechanism in Angular. We’ll learn how it works in JavaScript, why Angular uses it and how to implement a custom one.

Angular uses two JavaScript capabilities that are currently being standardized — decorators and metadata reflection API to allow declarative components definition. Currently they are not supported by the JS but both are on their track to become available in our browsers very soon. And since these features are not yet supported, Angular uses TypeScript compiler to allow the usage of decorators and reflect-metadata npm package to shim metadata reflection API. There is a great deal of articles on the web that describe decorators and metadata API in details. This article shows how they are used in Angular.

#angular #decorators #javascript

Implementing Custom Component Decorator in Angular
9.25 GEEK