routerLink在Angular 6中不起作用 [英] routerLink not working in Angular 6
本文介绍了routerLink在Angular 6中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习Angular 6
.
我已将应用程序结构设计为具有以下结构的层次结构形式.
I have designed my application structure in hierarchy form with following structure.
my_app
|- src
|- app
|- layout
|- admin-layout
|- admin-layout.module.ts
|- admin-layout.routing.ts
|- admin-layout.component.html
|- contacts
|- contact-list
|- contact-list.component.ts
|- contact-list.component.html
|- contacts.module.ts
|- transaction
|- amount-given
|- amount-given-list
|- amount-given-list.component.ts
|- amount-given-list.component.html
|- amount-given.module.ts
|- amount-given.routing.ts
|- amount-given.service.ts
|- transaction.module.ts
|- transaction.routing.ts
|- app.module.ts
|- app.component.html
|- app-routing.module.ts
可在此处找到源代码和演示图: https://stackblitz.com/edit/angular-wcglvr
The source code and demo illustration can be found here: https://stackblitz.com/edit/angular-wcglvr
<a routerLink="/dashboard">Dashboard</a>
在/transaction/amount-given/amount-given-list/
上工作,但在/contacts/contact-list
上工作.
is working from /transaction/amount-given/amount-given-list/
but not from /contacts/contact-list
.
由于源代码非常长且具有层次结构,因此我在 stackblitz 上添加了演示示例.
Since source code is quite long and hierarchical, I have added demo illustration on stackblitz.
推荐答案
您尚未在ContactsModule
中导入RouterModule
.
import {RouterModule} from '@angular/router';
@NgModule({
imports: [
RouterModule
],
这篇关于routerLink在Angular 6中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文