Mac OSX Sierra
angular-cli: 1.0.0-beta.21
node: 6.9.1
os: darwin x64
ng new foo
cd foo
ng g s bar
A warning message is shown that says
WARNING Service is generated but not provided, it must be provided to be used
Perhaps we can extend this to say
WARNING Service is generated but not provided, it must be provided to be used. Consider providing it in the closest NgModule [put module name here]. Read this link for more information about where to provide services [link to docs]
I think not providing the service is correct behavior for the CLI because it is not clear cut. But adding suggestions and/or a link to docs may help the user.
+1
+1 - clambered around why this wasn't working from the CLI turns out it was me moving files around and not receiving correct warnings, but this pointed me right at what I was missing. So no googling would have been required.
This could also be used when generating services: #3806
For services, I was thinking maybe a --provide option with support for several (tentatively named) keywords:
closest-module [default]closest-componentrootFor now I'm content with the warning showing when no additional config is provided and allowing the path of a module to be specified. Providing to a component is an approach that can be manually taken after viewing the provided warning.
When generating a service you can now specify where it will be provided with this PR #3811
ng g s services/apiservices --module=app.module
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
ng g s services/apiservices --module=app.module