13

Why in components or directives do the metadata or decorators have the @ symbol (e.g. @Component, @Directive)?

What is the purpose of it, and when should I use it?

double-beep
  • 5,031
  • 17
  • 33
  • 41
Adrian
  • 171
  • 1
  • 1
  • 6
  • 1
    shortcut for annotation – Pavel Gatnar Feb 24 '17 at 05:23
  • 3
    You might find reading this helpful. http://www.typescriptlang.org/docs/handbook/decorators.html – Hardik Modha Feb 24 '17 at 05:23
  • 1
    You should have run across this when you read the TypeScript documentation. Or, you could google for "typescript at-sign". –  Feb 24 '17 at 05:28
  • Possible duplicate of [What does the @ (at sign) mean in the latest TypeScript (presumably v1.5) example?](http://stackoverflow.com/questions/28906505/what-does-the-at-sign-mean-in-the-latest-typescript-presumably-v1-5-exampl) –  Feb 24 '17 at 05:30

1 Answers1

17

It stands for decorators. It is not TypeScript specific.

Google "javascript decorator" to learn more about it.

For example:

http://javascript.info/tutorial/decorators

https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.jzu13e5lr

For up to date information about their standard implementation and when it will finally be released (future ECMAScript versions), see this page: https://github.com/tc39/proposal-decorators

And as @hardikModha mentioned, you can also look up the TypeScript handbook: http://www.typescriptlang.org/docs/handbook/decorators.html

unional
  • 14,651
  • 5
  • 32
  • 56