创建新实体时不会自动生成相对路由 [英] Relative routes are not automatically generated when creating a new entity

查看:148
本文介绍了创建新实体时不会自动生成相对路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 jhipster实体[entityName]命令创建新实体时,相对路径不会自动在我的[entityName] .route.ts中生成。

When I create a new entity with the command "jhipster entity [entityName]", the relative paths are not automatically generated in my [entityName].route.ts.

相反,在主要路线的地方,我有:',而不是'[entity-name]'。

Instead, at the place for the main route I have this : ' ', instead of '[entity-name]'.

此外,所有添加路线,更新和删除也不包含前缀 [实体名称]。

Also, all the routes for adding, updating and deleting also not contains the prefix '[entity-name]'.

预先感谢您

推荐答案

entity.module.ts 中,到实体的路由被添加到 RouterModule.forChild()中:所有实体都将延迟加载。

In entity.module.ts, the routes to the entities get added in RouterModule.forChild(): all entities will be lazy loading.

这意味着在客户端(浏览器)中加载的由JHipster创建的Angular应用的初始部分没有应用程序的所有路径和所有模块。 Angular应用程序的一个也是唯一的Angular路由器对象最初只知道 app-routing.module中 RouterModule.forRoot()中定义的路径。 ts (在 app.module.ts 中作为 [AppName] AppRoutingModule] 导入)和 navbar.route.ts (在 app-routing.module.ts 中链接)。

This means the initial part of the JHipster-created Angular app loaded in a client (Browser) does not have all paths and all modules of the app. The one and only Angular Router-Object of an Angular application initially only knows the paths defined in RouterModule.forRoot() in app-routing.module.ts (which is imported as [AppName]AppRoutingModule] in app.module.ts) and navbar.route.ts (which is linked in app-routing.module.ts).

entity.module.ts 本身作为 [AppName] EntityModule app.module.ts 中的c>,因此其 RouterModule.forChild()条目-对象直接从客户端浏览器中的应用程序开始。

The entity.module.ts itself is imported as [AppName]EntityModule in app.module.ts and therefore its RouterModule.forChild()-entries are known to the Angular Router-Object right from app start in the client browser.

这样,客户端上的Angular Router-Object将仅知道路径以及如何导航至已实现的实体模块(表示:如何在SPA的屏幕上加载实体组件),因此仅在访问此实体的情况下延迟加载相应的 js -来自Webserv的数据客户端(浏览器)。 Angular在转译时将这些数据打包为javascript块,因此可以分别加载相应的其他数据。

This way, the Angular Router-Object on the client will only know the paths and how to navigate to an implemented entity module (means: how to load the entities components on the screen of the SPA) if asked to and therefore will only in the case this entity gets visited "lazy load" the corresponding js-data from Webserver to client (Browser). Angular packages this data on transpilation in javascript chunks, so the corresponding additional data can be loaded separately.

在每个JHipster Webapp实体文件夹中,您都会找到 [entity] .route.ts ,由相应的 [entity] .module.ts 导入。

In every JHipster webapp entity folder, you will find an [entity].route.ts, which gets imported by the corresponding [entity].module.ts.

因此,只要通过路径访问其中一个实体组件,客户端上的Angular Router-Object就会获得更多信息(路径),如何加载其他Angular组件(完整的JHipster-创建的实体)与 RouterModule.forChild 中的 loadChildren

So as soon as one of the entities components will be visited via path, the Angular Router-Object on the client gets further information (paths), how to load additional Angular components (a complete JHipster-created entity) with loadChildren in RouterModule.forChild.

这些功能模块组件模板将位于路径上: (分别为 path:':id / view' path:':id / edit' path:':id / new')添加到它们来自的根路径中:< base href = / / > (来自 inde x.html )+ ./ [实体] / (来自 entity.module.ts

These feature modules components templates will then be on path: '' (respectively path: ':id/view', path: ':id/edit', path: ':id/new') added to the root-path they came from: <base href="/" /> (from index.html) + ./[entity]/ (from entity.module.ts).

还会为相应的出口的前端Angular端生成相应的出口名称(如果已命名),路由保护和pageTitles以及单独的其他路由参数。 JHipster应用程序。目前,JHipster生成两个< router-outlet> s:一个用于页面顶部的导航栏(这是命名的),而主要的是<路由器插座>

Together with the corresponding outlet name (if named), route guards and pageTitles as well as individual additional route parameters are also generated for the frontend Angular side of a JHipster App. JHipster at the moment generates two <router-outlet>s: one for the navbar at the top of the page (this is the named one) and the main <router-outlet>.

这篇关于创建新实体时不会自动生成相对路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆