- When writing our application in TypeScript, we use decorators to add metadata to our code.
- In our article on the difference between decorators and annotations we learned that decorators simply add metadata to our code.
- The metadata is the one that is needed by Angular’s DI to figure out, for what type it has to return an instance.
- TypeScript only generates metadata for a class, method, property or method/constructor parameter when a decorator is actually attached to that particular code.
- All we have to do is to import it and put it on our like this:
Again, this will just enforce TypeScript to emit the needed metadata, the decorator itself doesn’t have any special meaning here.
Which skill level is the ideal audience for this? Resolving Service Dependencies in Angular 2 > https://t.co/aFiWWFoq5U
— AngularJS News (@AngularJS_News) July 28, 2017
Tweets by PascalPrecht
Tweets by timche_
Tweets by tim_hartmann_