Reputation: 918
I'm following the Angular2 routes tutorial. I'm trying to redirect the default router '' to 'enderecamento' and i got this error on the console:
My routing code is the following:
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);
The strange thing is, if I change:
[...]
children: [
{ path: 'enderecamento', component: EnderecamentoComponent,},
{ path: '', redirectTo: 'enderecamento', pathMatch: 'full' }
]
[...]
To this:
[...]
children: [
{ path: 'enderecamento', component: EnderecamentoComponent,},
{ path: '', component: EnderecamentoComponent, }
]
[...]
The 'enderecamento' page is loaded, but if iIclick on a routerLink in the page to redirect it or write on the context 'pecaJuridica/enderecamento'i got the same Uncaught promise [object Object] error, is there a way to debug it? It's very frustrating because I know it must be a simple thing, and those error messages aren't intuitive to me..
Some additional info:
Redirection plnkr:
Redirection routerLink plnkr:
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>
[...]
Upvotes: 1
Views: 162