简体   繁体   English

如何使用 workin routerlink 将组件正确添加到我的 Jhipster + Angular 项目中?

[英]How do i add properly create a component to my Jhipster + Angular project with a workin routerlink?

SO i generated a new application on jhipster and i have wanted to create a front side FAQ page for my web portal, i created it as an entity and it generated all the CRUD components (detail, delete, edit).所以我在 jhipster 上生成了一个新的应用程序,我想为我的门户网站创建一个前端常见问题页面,我将它创建为一个实体,它生成了所有的 CRUD 组件(详细信息、删除、编辑)。 This of course in the jhipster template looks like an admin/user view table with buttons to view, edit or delete.这当然在 jhipster 模板中看起来像一个管理员/用户视图表,带有用于查看、编辑或删除的按钮。 I want to make the FAQ public to visitors of the website without needing to have an account... So i generated a component 'faq-page' like the documentation says: https://www.jhipster.tech/using-angular/ only problem is the routerlink does not redirect me to '/faq' instead it redirects me to the 404 page.我想在不需要拥有帐户的情况下向网站访问者公开常见问题解答...所以我生成了一个组件“常见问题页面”,如文档所述: https : //www.jhipster.tech/using-angular/唯一的问题是 routerlink 不会将我重定向到“/faq”,而是将我重定向到 404 页面。 I created the 'faq-page' component based on the existing 'home' like below snippets:我根据现有的“主页”创建了“常见问题页面”组件,如下所示:

  • faq-page.component.html (just has some texts for now) faq-page.component.html(现在只有一些文本)

  • faq-page.component.ts常见问题页面.component.ts

     import { Component, OnInit } from '@angular/core'; @Component({ selector: 'jhi-faq-page', templateUrl: './faq-page.component.html', styleUrls: ['./faq-page.component.scss'] }) export class FaqPageComponent implements OnInit { constructor() { } ngOnInit() { } }

  • faq-page.module.ts常见问题页面.module.ts

 import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { TestAppSharedModule } from 'app/shared/shared.module'; import { FAQ_PAGE_ROUTE } from './faq-page.route'; import { FaqPageComponent } from './faq-page.component' @NgModule({ imports: [RouterModule.forChild([FAQ_PAGE_ROUTE]), TestAppSharedModule ], declarations: [FaqPageComponent] }) export class FaqModule { }

  • faq-page.route.ts常见问题页面.route.ts

 import { Route } from '@angular/router'; import { FaqPageComponent } from './faq-page.component'; export const FAQ_PAGE_ROUTE: Route = { path: 'faq', component: FaqPageComponent, data: { authorities: [], pageTitle: 'faq-page.title' } };

Check your app-routing.module.ts and make sure the ...LAYOUT_ROUTES, line comes last!检查您的 app-routing.module.ts 并确保...LAYOUT_ROUTES,行最后! ng generate will add your new component at the end, which will let the catch-all 404 page (contained in LAYOUT_ROUTES) match before your new page. ng generate将在最后添加您的新组件,这将使全能 404 页面(包含在 LAYOUT_ROUTES 中)在您的新页面之前匹配。 This needs to be printed somewhere in large friendly letters.这需要用大型友好字母打印在某处。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Storybook 与使用 [routerLink] (Angular) 的组件一起使用? - How to use Storybook with a component using [routerLink] (Angular)? 在Angular 2+中,我可以检测到何时将指令(如routerLink)应用于我的自定义组件吗? - In Angular 2+, can I detect when a directive (like routerLink) is applied to my custom component? 如何在没有routerLink的情况下添加queryParams单击角度? - How to add queryParams without routerLink Click in angular? 如何在Angular 2项目的Karma配置中“将提供的文件作为依赖项添加”? - How do I “add a served file as a dependency” in my Karma configuration for an Angular 2 project? routerLink 在我的 angular 离子项目中不起作用 - the routerLink doesn't work in my angular ionic project 如何将纯javascript文件添加到Angular 4组件中? - How do I add pure javascript files into Angular 4 component? Angular路由器:如何根据路由器的一部分重定向到一个组件link - Angular router : how to redirect to a component based on a part of the routerlink Angular:如何将我的用户搜索输入数据传输到另一个组件并从搜索结果中创建一个列表? - Angular: How do I transfer my usersearch-input data into another component and create from the search result a list? 如何在 angular-cli 项目中添加另一个页面? - How do I add another page in an angular-cli project? 我如何添加一个<img>在我的 React 组件中? - How do I add an <img> in my React component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM