angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

More help with providing services

Open johnpapa opened this issue 9 years ago • 8 comments

OS?

Mac OSX Sierra

Versions.

angular-cli: 1.0.0-beta.21 node: 6.9.1 os: darwin x64

Repro steps

ng new foo
cd foo
ng g s bar

Suggestion

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]

Details

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.

johnpapa avatar Dec 03 '16 15:12 johnpapa

+1

digimax avatar Dec 03 '16 15:12 digimax

+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.

iainplimmer avatar Dec 20 '16 10:12 iainplimmer

This could also be used when generating services: #3806

Brocco avatar Dec 31 '16 15:12 Brocco

For services, I was thinking maybe a --provide option with support for several (tentatively named) keywords:

  • closest-module [default]
  • closest-component
  • root

clydin avatar Dec 31 '16 15:12 clydin

For 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.

Brocco avatar Jan 15 '17 03:01 Brocco

When generating a service you can now specify where it will be provided with this PR #3811

Brocco avatar Feb 10 '17 04:02 Brocco

ng g s services/apiservices --module=app.module

sabbarbutt avatar Apr 24 '17 16:04 sabbarbutt

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.