Skip to content

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

Closed

Description

@cyrilletuzi

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]
})

Activity

  1. cyrilletuzi commented on Jul 28, 2017

    @cyrilletuzi
    ContributorAuthor

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

    function _addSymbolToNgModuleMetadata(ngModulePath: string, metadataField: string,

  2. cyrilletuzi commented on Aug 18, 2017

    @cyrilletuzi
    ContributorAuthor

    @hansl Still there with the schematics

  3. denniske commented on Sep 20, 2017

    @denniske

    Created pull request with fix. Can somebody review?

  4. cyrilletuzi commented on Dec 8, 2017

    @cyrilletuzi
    ContributorAuthor

    @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 ?

  5. cyrilletuzi commented on Jan 13, 2018

    @cyrilletuzi
    ContributorAuthor

    @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 ?

  6. added and removed
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Feb 1, 2018
  7. cyrilletuzi commented on Feb 8, 2018

    @cyrilletuzi
    ContributorAuthor

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

  8. cyrilletuzi commented on Mar 23, 2018

    @cyrilletuzi
    ContributorAuthor

    Will this be fixed in v6 ?

  9. cyrilletuzi commented on Apr 25, 2018

    @cyrilletuzi
    ContributorAuthor

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

  10. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  11. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions