有没有办法在angular中的app-module.ts中生成自动导入的路由器模块?
Is there a way to generate a router module that will automatically be imported in app-module.ts in angular?
我想为我的 angular 6 项目使用新的路由器模块,所以我想知道是否有办法生成 angular 7 的新路由器模块,它将自动导入到应用程序中- module.ts?
没有。在 angular 4+ 平台中 'ng new' 支持交互式添加路由。在 ng7 中实现路由与在 ng6 中相同。您可以使用 ng g module <moduele-name>
手动添加模块。后来,import RouterModule from @angular/router
.
也就是说,当您的项目在 ng6 上时,我看不出您想使用 ng7 中的路由的原因。两者都支持儿童的延迟加载。 IMO,将整个项目迁移到一个版本更有意义。
https://www.techiediaries.com/angular-routing-lazy-loading-loadchildren/
我想为我的 angular 6 项目使用新的路由器模块,所以我想知道是否有办法生成 angular 7 的新路由器模块,它将自动导入到应用程序中- module.ts?
没有。在 angular 4+ 平台中 'ng new' 支持交互式添加路由。在 ng7 中实现路由与在 ng6 中相同。您可以使用 ng g module <moduele-name>
手动添加模块。后来,import RouterModule from @angular/router
.
也就是说,当您的项目在 ng6 上时,我看不出您想使用 ng7 中的路由的原因。两者都支持儿童的延迟加载。 IMO,将整个项目迁移到一个版本更有意义。
https://www.techiediaries.com/angular-routing-lazy-loading-loadchildren/