Skip to content
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

Import Module while generating Submodule with --routing uses RoutingModule #6533

Closed
web-dave opened this issue Jun 1, 2017 · 16 comments
Closed

Comments

@web-dave
Copy link

web-dave commented Jun 1, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.1.0
node: 6.9.4
os: win32 x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.1.0
@angular/compiler-cli: 4.1.3
@angular/language-service: 4.1.3

Repro steps.

  • I simple started a Project with ng new bar --routing
  • Then i want to generate a submodule ng g module foo --routing -m=app.modules

The log given by the failure.

Output:

  create src\app\foo2\foo-routing.module.ts
  create src\app\foo2\foo.module.ts
  update src\app\app.module.ts
  • app.module.ts:
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FooRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

Desired functionality.

FooModule should be imported!

Mention any other details that might be useful.

@web-dave web-dave changed the title Import Module while generating uses wrong module Import Module while generating Submodule with --routing uses RoutingModule Jun 1, 2017
@web-dave
Copy link
Author

web-dave commented Jun 1, 2017

It seems to happen only if I generate a module with --routing

@sumitarora sumitarora self-assigned this Jun 1, 2017
@cyrilletuzi
Copy link
Contributor

I confirm this issue.

@sumitarora
Copy link
Contributor

@web-dave @cyrilletuzi It's work fine just 1 typo ng g module foo --routing -m=app.module instead of ng g module foo --routing -m=app.modules

@cyrilletuzi
Copy link
Contributor

Well in my case, it was not this typo, it was because I was induced in error by the issue (indicated in the changelog #5377) this new feature solved, where it's written without a = :
ng g module test -m app.module

As ng g module test -m throws and ng g module test -m badpath/app.module throws too, I thought it was an alternative syntax I didn't know.

Shouldn't the CLI throws in case of typos instead of doing something weird ?

@web-dave
Copy link
Author

web-dave commented Jun 2, 2017

My Super hero power: Typos!!
But confusing, cause without --routing it works.

@sumitarora
Copy link
Contributor

@cyrilletuzi It does work as expected. I checked it again. Do you have steps to replicate the exact issue?

@cyrilletuzi
Copy link
Contributor

ng new app --routing
ng g module test -m app --routing

without =

AppModule imports TestRoutingModule instead of TestModule

@clydin
Copy link
Member

clydin commented Jun 7, 2017

This appears to be the suspect code block: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/blueprints/module/index.ts#L127

@cyrilletuzi
Copy link
Contributor

Now this issue happens with the normal and official commands :

ng new someapp --routing --skip-git
ng g module test --routing --module=app.module

results in TestRoutingModule imported in AppModule instead of TestModule.

That's a major issue.

@cyrilletuzi
Copy link
Contributor

cyrilletuzi commented Jul 2, 2017

Still here in cli 1.2.0. Submitted a PR.

@cyrilletuzi
Copy link
Contributor

Can someone review my PR ? It's a really annoying issue.

@shairez
Copy link
Contributor

shairez commented Aug 7, 2017

@Brocco or @filipesilva
Seems like there is a PR for this issue, have you got a chance to review it yet?

#goodnessSquad

@hansl
Copy link
Contributor

hansl commented Aug 17, 2017

Fixed in Schematics.

@hansl hansl closed this as completed Aug 17, 2017
@doggy8088
Copy link
Contributor

doggy8088 commented Aug 18, 2017

@hansl I tested. It works. Thank you! But the ng g m no longer working. It can only be use ng g module to generate a new module. Is it a known issue?

@Brocco
Copy link
Contributor

Brocco commented Aug 21, 2017

@doggy8088 It is a known issue that I am actively working on.

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.