Reader small image

You're reading from  Getting Started with Angular - Second edition - Second Edition

Product typeBook
Published inFeb 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787125278
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Minko Gechev
Minko Gechev
author image
Minko Gechev

Minko Gechev is a software engineer who strongly believes in open source software. He has developed numerous such projects including codelyzer, the AngularJS style guide, aspect.js and many others, and is one of the coauthors of the official Angular style guide.
Read more about Minko Gechev

Right arrow

Meta-programming with ES2016 decorators


JavaScript is a dynamic language that allows us to easily modify and/or alter the behavior to suit the programs we write. Decorators are a proposal to ES2016, which according to the design document https://github.com/wycats/javascript-decorators:

"...make it possible to annotate and modify classes and properties at design time."

Their syntaxes are quite similar to the annotations in Java, and they are even closer to the decorators in Python. ES2016 decorators are used commonly in Angular to define components, directives, and pipes, and to take advantage of the dependency injection mechanism of the framework. Most use cases of decorators involve altering the behavior to a predefined logic or adding some metadata to different constructs.

ES2016 decorators allow us to do a lot of fancy things by changing the behavior of our programs. Typical use cases could be to annotate the given methods or properties as deprecated or read-only. A set of predefined decorators...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Getting Started with Angular - Second edition - Second Edition
Published in: Feb 2017Publisher: PacktISBN-13: 9781787125278

Author (1)

author image
Minko Gechev

Minko Gechev is a software engineer who strongly believes in open source software. He has developed numerous such projects including codelyzer, the AngularJS style guide, aspect.js and many others, and is one of the coauthors of the official Angular style guide.
Read more about Minko Gechev