Angular 6辅助routerLink无效

时间:2018-10-19 13:34:52

标签: angular typescript angular-ui-router angular6

我已经在组件中配置了路由并创建了辅助路由器出口,但是我既不能转到URL路径,也无法通过routerLink绑定它。

我的命名路由器的根组件工作正常,但其他组件未得到访问。以下是参考代码,欢迎提出解决方案。

任何尝试访问到达应用程序主页的路线登陆的信息。我什至手动尝试像这样访问它: http://localhost:4200/profile/projects(rightpanel:addtask) http://localhost:4200/profile/projects/(rightpanel:addtask) http://localhost:4200/profile/projects/projaddedit/(rightpanel:addtask)

但没有任何效果,即使在我尝试过的routerlink中,它也无济于事:

<a [routerLink]="[{ outlets: { rightpanel: 'addtask' }}]" class="btn">Link to Add Task</a>
<a [routerLink]="['/profile/projects', { outlets: { rightpanel: 'addtask' }}]" class="btn">Link to Add Task</a>

路由器组件:

<split-area size="40">
    <router-outlet ></router-outlet>
</split-area>

<split-area size="60">
    <a [routerLink]="['/profile/project', {outlets: {rightpanel: 'addmilestone'}}]">Go to Adds Milestone</a>
    <router-outlet name="rightpanel"></router-outlet>
</split-area>

路由器配置:

   const routes: Routes = [
      {
        path: '', component: ProjectsComponent,
        children: [
          {
            path: '',
            loadChildren: './proj-list/proj-list.module#ProjListModule',
          },
          {
            path: 'projaddedit',
            loadChildren: './proj-add-edit/proj-add-edit.module#ProjAddEditModule',
          },
          {
            path: 'subproj',
            component: SubProjComponent,
          },
          {
            path: 'resources',
            component: ResourcesComponent,
          },
          {
            path: '',
            component: AddMilestoneComponent,
            outlet: 'rightpanel'
          },
          {
            path: 'addmilestone',
            component: ProjDetailsComponent,
            outlet: 'rightpanel'
          },
          {
            path: 'addtask',
            component: AddTaskComponent,
            outlet: 'rightpanel'
          }
        ]
      }
    ];

0 个答案:

没有答案