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

Đang mở
#24,497 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Tái hiện ng g m foo --route=foo -m=app trong một dự án Angular 15 sử dụng provideRouter, sau đó kiểm tra cách xử lý route khi tạo module so với app-routing.module.tsapp.module.ts. Được xem là hoàn tất khi lệnh tìm thấy khai báo route đã được export và tạo module với route được yêu cầu mà không có lỗi được hiển thị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: @schematics/angular freq1: low severity3: broken type: bug/fix
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.
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
16 giờ 35 phút
Pull request đã merge (30 ngày)
176

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.