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

ng g module with route option not working with the new provideRouter

Open robertIsaac opened this issue 3 years ago • 4 comments

Command

generate

Is this a regression?

  • [ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

when using the new way provideRouter the command ng g m foo --route=foo -m=app stop working

Minimal Reproduction

create new angular 15 project in app-routing.module.ts

  1. remove AppRoutingModule
  2. export the routes const

in app.module.ts

  1. remove AppRoutingModule from import array
  2. add provideRouter(routes) to the providers array

then in the command line run ng g m foo --route=foo -m=app

Exception or Error

Couldn't find a route declaration in /src/app/app-routing.module.ts.
Use the '--module' option to specify a different routing module.

Your Environment

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.5
@angular-devkit/build-angular   15.0.5
@angular-devkit/core            15.0.5
@angular-devkit/schematics      15.0.5
@angular/cli                    15.0.5
@schematics/angular             15.0.5
rxjs                            7.5.7
typescript                      4.8.4

Anything else relevant?

changing the file name from app-routing.module.ts to routes.ts gives a different but similar error message

Couldn't find a route declaration in /src/app/app.module.ts.
Use the '--module' option to specify a different routing module.

robertIsaac avatar Jan 06 '23 19:01 robertIsaac

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

angular-robot[bot] avatar Jan 09 '23 13:01 angular-robot[bot]

@alan-agius4 why this needs to be voted for to be fixed?

robertIsaac avatar Jan 09 '23 15:01 robertIsaac

@robertIsaac it shouldn’t 😀

alan-agius4 avatar Jan 09 '23 15:01 alan-agius4

I would like to take this up. Could you please assign it to me @alan-agius4 ?

sumitparakh avatar Mar 25 '23 19:03 sumitparakh