私はAngular2 routes チュートリアルに従っています。デフォルト ルーター '' を 'enderecamento' にリダイレクトしようとすると、コンソールに次のエラーが表示されます。
私のルーティングコードは次のとおりです。
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」ページが読み込まれますが、ページ内の routerLink をクリックしてリダイレクトするか、コンテキスト「pecaJuridica/enderecamento」に書き込むと、同じ Uncaught promise [object Object] エラーが発生しました。デバッグする方法はありますか? それは単純なものでなければならないことを知っているので、非常にイライラします..
いくつかの追加情報:
リダイレクト plnkr:
リダイレクション routerLink plnkr:
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>
[...]