Implementing custom component decorator in Angular – Angular In Depth

Whenever we need to define a new component in Angular we use @Component decorator like this:@Component({ selector: ‘my-app’, template: ‘spanI am a component/span’,})export class AppComponent { name = ‘Angular’;}The spec defines a decorator as an expression that evaluates to a function that takes the target, name, and decorator descriptor as…

Letâs implement that:export function { _props = Object.assign({}, defaultProps, _props); return function (cls) { }}I also mentioned that the single purpose of a decorator in Angular is to attach metadata to a class.