Skip to content

Generate service : providers registered in the wrong place if { provide } is present #7061

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
cyrilletuzi opened this issue Jul 20, 2017 · 9 comments

Comments

@cyrilletuzi
Copy link
Contributor

cyrilletuzi commented Jul 20, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

cli 1.2.1

Repro steps.

ng new test
cd test
ng g service hello

Then in AppModule, provide it like this :

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [{ provide: HelloService, useClass: HelloService}],
  bootstrap: [AppComponent]
})

Now, if you generate new services, with module registering option :

ng g service world --module=app

It produces :

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [{provide: HelloService, useClass: HelloService, providers: [WorldService]}],
  bootstrap: [AppComponent]
})
@cyrilletuzi
Copy link
Contributor Author

The problem may be coming from this function, but didn't find yet why :

function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: string,

@cyrilletuzi
Copy link
Contributor Author

@hansl Still there with the schematics

@denniske
Copy link

Created pull request with fix. Can somebody review?

@cyrilletuzi
Copy link
Contributor Author

@filipesilva @Brocco This issue has been marked as a regression and is 4 months old, and has a PR waiting which is 2 months old. Can someone take care of it ?

@cyrilletuzi
Copy link
Contributor Author

@hansl @filipesilva @Brocco This issue has been marked as a regression and is 5 months old, and has a PR waiting which is 3 months old. Can someone take care of it ?

@hansl hansl unassigned Brocco Feb 1, 2018
@hansl hansl added freq3: high and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity5: regression labels Feb 1, 2018
@cyrilletuzi
Copy link
Contributor Author

Happy to see someone is caring for this issue, but quite disagree with the new severity level : it's not just "inconvenient", it produces code that break compilation. So it should at least be "severity3: broken".

@cyrilletuzi
Copy link
Contributor Author

Will this be fixed in v6 ?

@cyrilletuzi
Copy link
Contributor Author

As in v6 services are not provided in the NgModule anymore, the issue is gone.

@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

5 participants