我正在使用带有材质框架的angular 7。我正在通过路由器处理菜单,实际上它正在工作,但是一个链接没有注册。我确实在模块和路由中添加了它。我在下面附加了渲染的DOM:
这是我的AppComponent.ts内容
<mat-nav-list class="sidenav-submenu" *ngIf="showMenu">
<a mat-list-item routerLink="/BlockMaster"><fa name="building"></fa> Block Master</a>
<a mat-list-item routerLink="/FloorMaster"><fa name="building"></fa> Floor Master</a>
<a mat-list-item routerLink="/CellMaster"><fa name="lock"></fa> Cell Master</a>
<a mat-list-item routerlink="/LocatorMaster"><fa name="location-arrow"></fa> Locator Master</a>
<a mat-list-item routerLink="/TagMaster"><fa name="tags"></fa> Tag Master</a>
<a mat-list-item routerLink="/TagMember"><fa name="users"></fa> Member Master</a>
<a mat-list-item routerLink="/VisitorConfRoom"><fa name="street-view"></fa> Visitor Conf Room Master</a>
<a mat-list-item routerLink="/PrisonerConfRoom"><fa name="university"></fa> Prisoner Conf Room Master</a>
<a mat-list-item routerLink="/MapLocator"><fa name="university"></fa> Map Locator</a>
<a mat-list-item routerLink="/TagTracker"><fa name="university"></fa> Tag Tracker</a>
</mat-nav-list>
我的路由配置如下:
Routes = [
{ path: '', component: HomeComponent, canActivate: [AuthGuard] },
{ path: 'CellMaster', component: CellMasterComponent, canActivate: [AuthGuard] },
{ path: 'TagMaster', component: TagMasterComponent, canActivate: [AuthGuard] },
{ path: 'TagMember', component: TagMemberComponent, canActivate: [AuthGuard] },
{ path: 'LocatorMaster', component: LocatorMasterComponent, canActivate: [AuthGuard] },
{ path: 'BlockMaster', component: BlockMasterComponent, canActivate: [AuthGuard] },
{ path: 'FloorMaster', component: FloorMasterComponent, canActivate: [AuthGuard] },
{ path: 'VisitorConfRoom', component: VisitorConfRoomMasterComponent, canActivate: [AuthGuard] },
{ path: 'PrisonerConfRoom', component: PrisonerConfRoomMasterComponent, canActivate: [AuthGuard] },
{ path: 'MapLocator', component: MapLocatorComponent, canActivate: [AuthGuard] },
{ path: 'TagTracker', component: TagTrackerComponent, canActivate: [AuthGuard] }];
我不确定是什么问题。
答案 0 :(得分:0)
尝试将routerLinkActive="active"
添加到您的标签
示例:
<a mat-list-item routerLink="/BlockMaster" routerLinkActive="active">
<fa name="building"></fa> Block Master
</a>
答案 1 :(得分:0)
您写错了。 router[l]ink="/LocatorMaster"
=> router[L]ink="/LocatorMaster"