Decorators
Decorators are not a new programming concept, but are one of the structural design patterns, along with the facade and flyweight patterns. In JavaScript, we do not have any implementation of the decorator pattern as of now, though currently they are in a stage two proposal. In TypeScript also, decorators are an experimental feature that may end up changing in implementation depending on how ECMA finalizes the implementation in JavaScript.
Let's first look at what the decorator design pattern states and where is it applicable. Following that, we will look at the TypeScript implementation of the decorator pattern. In Angular, we have decorators such as @Component, @NgModel, and @Injectable, which we will take a brief look at.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access