Decorators

The most common feature introduced in Angular 2+ is decorators. Decorators, at first glance, are confusing because of the unusual @ sign preceding their usage:

The preceding screenshot is a code snippet from an Angular application. It shows a component decorator decorating a class called AppComponent.

At first, this might look overwhelming because, in the history of JavaScript, I have never seen the @ literal used this way. If only we knew it was just a function that had access to the members of what it is decorating! Classes, properties, methods, and accessors are all allowed to be decorated. Let's discuss how to decorate methods ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.