O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parameter decorators

Parameter decorators are prefixed to parameter declarations, and they are applied to a function for a class constructor or method declaration. This is the signature of ParameterDecorator:

declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; 

Now, let's define the Customer class and use a parameter decorator to decorate a parameter in order to make it required, and validate whether the value has been served:

class Customer {     constructor() {    }     getName(@logging name: string) {         return name;     } } 

Here, the name parameter has been decorated with @logging. The parameter decorator implicitly takes three inputs, namely prototype of the class that has this decorator, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required