Daughter routes at angular4

Asked

Viewed 241 times

0

Hello, I’m encountering problems with my daughter routes.

Just follow my lead:

export const ROUTES: Routes = [
    { path: '', redirectTo: 'Login', pathMatch: 'full' },
    { path: 'Login', component: Login },
    { path: 'Cadastro', component: CadastroUser, children: 
        [
            { path: '', redirectTo: 'dados-pessoais', pathMatch: 'full' },
            { path: 'dados-pessoais', component: DadosPessoais},
            { path: 'bancos', component: CadastroBancos}
        ] 
    }
]

I’m having problems in the path’s daughter routes: 'Register'.

The problem is that I am inside the route: 'registration/ personal data', and I created a button this way:

<button class="btn" [routerLink]="['bancos']">Proximo Passo</button>

To go to the route: 'register/ banks'.

But this error is presented:

inserir a descrição da imagem aqui

My outlet call goes like this:

<router-outlet></router-outlet>

Could someone help me?

1 answer

1


William, your route is to /cadastro/bancos and not to /cadastro/dados-pessoais/bancos as it is being sent. Changes your button to redirect to

['/cadastro/bancos']

or creates a new Child in your personal data:

 { path: 'dados-pessoais', component: DadosPessoais , children:
    [
       { path: 'bancos', component: CadastroBancos}
    ]
}
  • I changed the button as said above and the return was: 'Error: Cannot match any Routes. URL Segment: 'register/banks''

  • @Guilhermenunes have the <base href=". /"> in index.html ?

  • Yes. In the same way.

  • tries to change to Register/ banks , with the main.

  • Now it’s gone! rsrs, what a wobble my rsrs, thank you

  • heheh I tmb did not notice that heheh ! Thanks ! D

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.