那是我的傻瓜:
https://plnkr.co/edit/C9W0pHvy27J83m25YUOJ?p=preview
这些是回溯问题的步骤:
/projects/1/tests
然后/projects/2/tests
为什么活动类被有角度删除?
目前这不起作用,请参阅#13865
***app.module.ts***
{ path: 'projects', component: ProjectListComponent , children: [
{ path: '', redirectTo: 'tests', pathMatch: 'full' }, /* projects/id causes can not match any route */
{ path: ':id/tests', component: TestsListComponent },
]
},
{ path: '', redirectTo: 'projects', pathMatch: 'full' },
{ path: '**', component: NoRouteFoundComponent } /
];
项目-list.component.html
<nav style="background:gray;">
<select (ngModelChange)="onChangeProject($event)" [(ngModel)]="currentProject">
<option *ngFor="let p of projects" [ngValue]="p">
{{p.name}}
</option>
</select>
<button [disabled]="!currentProject" (click)="open()">Open project</button>
<a *ngIf="isMenuVisible" [routerLink]="['/projects', currentProject.id, 'tests']"
[routerLinkActiveOptions]="{ exact: true, __change_detection_hack__: currentProject.id }" >Tests link
</a>
<span>Logged out</span>
你应该添加:[routerLinkActiveOptions] =“{exact:true,change_detection_hack:currentProject.id}”