我正在关注the Angular2 routes tutorial . 我'm trying to redirect the default router ' ' to ' enderecamento'我在控制台上收到此错误:
image

我的路由代码如下:

app.routing.ts:

export const appRoutingProviders: any[] = [
];

const pecaJuridicaRoutes: Routes = [
  {
    path: '',
    redirectTo: 'pecaJuridica',
    pathMatch: 'full'
  },
  {
    path: 'pecaJuridica',
    component: PecaJuridicaComponent,
    pathMatch: 'full',
    children: [
      { path: 'enderecamento', component: EnderecamentoComponent,},
      { path: '', redirectTo: 'enderecamento', pathMatch: 'full' }
    ]
  },
];
console.log(pecaJuridicaRoutes);


const appRoutes: Routes = [
  ...pecaJuridicaRoutes,
];

export const routing = RouterModule.forRoot(appRoutes);

奇怪的是,如果我改变:

[...]
children: [
      { path: 'enderecamento', component: EnderecamentoComponent,},
      { path: '', redirectTo: 'enderecamento', pathMatch: 'full' }
    ]
[...]

对此:

[...]
children: [
      { path: 'enderecamento', component: EnderecamentoComponent,},
      { path: '', component: EnderecamentoComponent, }
    ]
[...]

'enderecamento'页面已加载,但是如果iIclick在页面中的routerLink上重定向它或在上下文'pecaJuridica / enderecamento'上写入得到相同的Uncaught promise [object Object]错误,有没有办法调试它?这非常令人沮丧,因为我知道它必须是一件简单的事情,而这些错误信息对我来说并不直观 .

一些额外的信息:

Redirection plnkr:

http://plnkr.co/edit/xRu4pS

Redirection routerLink plnkr:

http://plnkr.co/edit/d4xRtw

routerLink html code:

[...]
<ul class="sidebar-nav" id="sidebar">     
                            <li>
                                <a routerLink="enderecamento" routerLinkActive="focus" *ngFor="let button of buttons; let index = index">
                                    <span >{{button.label}}</span>
                                    <span  class="sub_icon glyphicon {{button.class}}" >
                                    </span>
                                </a>
                            </li>
                        </ul>
[...]