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

Accessor decorators

 

Accessor decorators are prefixed before the accessor declaration. These decorators are used to observe, modify, or replace an accessor definition and are applied to the property descriptor. The following code snippet shows a simple class with the accessor decorator applied:

class Customer {    private _firstname: string;   private _lastname: string;   constructor(firstname: string, lastname: string) {         this._firstname = firstname;         this._lastname = lastname;   }   @logging(false)   get firstname() { return this._firstname; }   @logging(false)   get lastname() { return this._lastname; } } 

In this class, we decorate the get accessor of firstname and lastname with @logging and pass boolean to enable or disable logging. The following ...

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