Search code examples
angulartypescriptangular2-decorators

What is the @ symbol in TypeScript?


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?


Solution

  • 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