Issue
I am confused when to use term annotation and when to use decorator ?
@Component({
selector: 'tabs',
template: `
`
})
export class Tabs {
}
Solution
A decorator corresponds to a function that is called on the class whereas annotations are "only" metadata set on the class using the Reflect Metadata library.
With TypeScript and ES7, @Something
is a decorator. In the context of Angular2, decorators like @Component
, @Injectable
, ... define metadata for the decorated element using the Reflect.defineMetadata
method.
This question could interest you to find out what a decorator actually is:
Answered By - Thierry Templier
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.