New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service is injectable without Injectable decorator #12098
Comments
I think it's documentation issue. |
Yes, the documentation should be fixed. |
Documentation issue created: angular/angular.io#2546 |
I don't think it's a documentation issue necessarily, you could just as well argue that the decorator is poorly named and should be given a new name like |
The document may mislead us about the meaning of the |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
The documentation of Injectable says:
The CLI also adds Injectable to all the services it creates, and the tutorial explains that a service must have this annotation.
However, a simple experiment with a component using a service not annotated with Injectable works fine (see http://plnkr.co/edit/IJVf79C1D8bNVLg9Kh2f?p=preview for example). It seems that the Injectable annotation is actually only needed if the service itself has dependencies that must be injected in its constructor, but that doesn't match with what the documentation says.
Expected behavior
angular should throw an error when an injector is trying to create an instance of a service not decorated with Injectable. Or the documentation should be fixed to explain what Injectable really is for.
Minimal reproduction of the problem with instructions
Launch this plunkr: http://plnkr.co/edit/IJVf79C1D8bNVLg9Kh2f?p=preview. Note that FooService is successfully created by the injector and injected into the app component, even though it doesn't have the Injectable decorator.
What is the motivation / use case for changing the behavior?
Make the documentation match the actual behavior of angular, or vice-versa
Please tell us about your environment:
NA. Happens on all environments.
Angular version: 2.0.X
Browser: all
Language: TypeScript
The text was updated successfully, but these errors were encountered: