RC5重定向子路由错误

时间:2016-08-22 21:03:40

标签: angular angular2-routing angular2-router

我正在关注the Angular2 routes tutorial。我正在尝试将默认路由器''重定向到'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'i得到了相同的Uncaught promise [object Object]错误,有没有办法调试吗?这非常令人沮丧,因为我知道它必须是一件简单的事情,这些错误信息对我来说并不直观。

其他一些信息:

重定向plnkr:

http://plnkr.co/edit/xRu4pS

重定向routerLink plnkr:

http://plnkr.co/edit/d4xRtw

routerLink html代码:

[...]
<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>
[...]

0 个答案:

没有答案