angular: 2.0.0-beta.9
Is it possible to inject a non @Injectable class into a component ? For example, this class could come from a Third party library.
@Injectable
component
Yes, it's possible. In fact the @Injectable decorator isn't to specify that a class is injectable into other ones but that you want to inject something in it at the level of its constructor.
If you don't want to inject something in your class, it's not mandatory to add the @Injectable decorator. This class can be injected into other ones.
I think that this Github issue could help you:
What is important here is to understand the difference between decorators and annotations. Here is a great article on this subject:
1.4m articles
1.4m replys
5 comments
56.8k users