Discover the power
of custom decorators
in Angular
@maartentibau
special
Koen Vanderlinden
@maartentibau
Hello!
I’m maarten
@maartentibau
Freelance
Software engineer
@maartentibau
Angular Trainer
@
@maartentibau
Core team member
NG-BE
@maartentibau
I love stickers !!
�#stickerguy
@maartentibau
What is a decorator ?
“A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter.�
Decorators use the form @expression, where expression must evaluate to a function that will be called at runtime with information about the decorated declaration.”
@maartentibau
source: https://www.typescriptlang.org/docs/handbook/decorators.html
types of decorators available in typescript
Class
@maartentibau
types of decorators available in typescript
Class
Method
@maartentibau
method decorator
class decorator
@maartentibau
source: https://www.thoughtram.io
types of decorators available in typescript
Class
Property
Method
@maartentibau
types of decorators available in typescript
Class
Property
Method
Param
@maartentibau
types of decorators available in typescript
Class
Property
Method
Param
@maartentibau
Accessor
parameter decorator
property decorator
@maartentibau
accessor decorator
source: https://www.typescriptlang.org/docs/handbook/decorators.html / https://www.thoughtram.io
how use custom decorators ?
@maartentibau
source: https://www.typescriptlang.org/docs/handbook/decorators.html
how use custom decorators ?
@maartentibau
Got you covered
Angular cli
@maartentibau
evaluation & execution process
@maartentibau
source: https://www.typescriptlang.org/docs/handbook/decorators.html
decorator factory
@maartentibau
source: https://www.typescriptlang.org/docs/handbook/decorators.html
target, propertykey, descriptor
@maartentibau
Either the constructor function of the class for a static member, or the prototype of the class for an instance member decorator
The name of the member
Property Descriptor
for the member
source: https://www.typescriptlang.org/docs/handbook/decorators.html
It’s just
A function !
@maartentibau
Property Descriptor
“Every object property is more than just a name and value pair. Each property is having property descriptor that helps to see all the attributes of that property.”
@maartentibau
source: https://codeburst.io/javascript-object-property-attributes-ac012be317e2
Property Descriptor
@maartentibau
@maartentibau
Thank you!!
Tak!!
tack själv!!
Kiitos!!
Takk skal du ha!!
Þakka þér fyrir!!
@maartentibau
template: https://www.slidescarnival.com/jachimo-free-presentation-template/1393