Decorators and Metadata
Enable experimental decorators, write class, method, and property decorators, and use reflect-metadata for dependency injection patterns.
What Are Decorators?
Decorators are functions that modify classes, methods, properties, or parameters at definition time. They're used heavily in Angular, NestJS, TypeORM, and class-based MobX.
Decorator Syntax
Prefix a class, method, property, or parameter with @DecoratorName. The decorator function runs when the class is defined.
@Component({ selector: 'app-root' })
export class AppComponent {
@Input() title: string;
@HostListener('click')
onClick() {
console.log('clicked');
}
}