1

私は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:

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

0 に答える 0