Skip to content

ng g s: Add ability to generate non-singleton services #11908

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

Closed
am-trinity opened this issue Aug 16, 2018 · 3 comments
Closed

ng g s: Add ability to generate non-singleton services #11908

am-trinity opened this issue Aug 16, 2018 · 3 comments

Comments

@am-trinity
Copy link

am-trinity commented Aug 16, 2018

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

$ node --version
v10.8.0
$ npm --version
6.3.0
$ ng --version
Angular CLI: 6.0.7
Node: 10.8.0
OS: linux x64

Repro steps

ng g service example

The log given by the failure

New service not included in parent module with:

...
@Injectable({
  providedIn: 'root',
})
...

Desired functionality

New service without providedIn: 'root' attribute and included in parent module.

Mention any other details that might be useful

@ngbot ngbot bot added this to the needsTriage milestone Aug 17, 2018
@hansl
Copy link
Contributor

hansl commented Aug 17, 2018

Hi @am-trinity ,

See discussion in #10170 (and many other places). Essentially Services are 99% singletons, and making a special case is actually more confusing for most users. It's a small change for you once the service is generated, so we decided to remove the option.

Please note that we never configured a provider in the past. We always created singleton services. I'm going to close this as working as intended.

Cheers!

@hansl hansl closed this as completed Aug 17, 2018
@am-trinity
Copy link
Author

I got it, thank you. Declarations like providedIn look very non-familiar and non-transparent (for the first time).

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants