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

Property decorators

Property decorators are prefixed to property declarations. The signature of PropertyDecorator in the TypeScript source code is this:

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

The following is a code snippet of a class with a property decorator applied to a property. In this code, the firstname property is decorated with the @hashify property decorator:

class Customer {    @hashify   public firstname: string;   public lastname: string;   constructor(firstname : string, lastname : string) {      this.firstname = firstname;     this.lastname = lastname;   } } 

Now, we will see the code snippet of the @hashify property decorator function:

function hashify(target: any, key: string) { 

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