Daughter Routes, Angular 5

0

I have a component, where it receives only one parameter in its route, like this:

{path: ':modelo', component: BaseNumerica, 

This component, in turn, has 3 child routes, described as follows:

{path: ':modelo', component: BaseNumerica, 
        children:  [
            {path: '', redirectTo: 'teste1', pathMatch: 'full'},
            {path: 'teste1', component: Personal},
            {path: 'teste2', component: Dealers},
            {path: 'teste3', component: Agendamento}
        ]},

I'm having difficulty accessing the 'test2' route, by the component of route 'test1', that is, in my component test1.html I have the following call:

[routerLink]="['teste2']"

and the following error is displayed:

Error: Cannot match any routes. URL Segment: 'modelo/teste1/teste2'

This error does not happen if I make the same button in the 'BaseNumerica' component. What should I do?

    
asked by anonymous 10.07.2018 / 18:05

1 answer

1

Guilherme this happens because just passing test2 he understands that you plan to access a level above the current one. So from BaseNumerica you access test2 without problems passing only it. To access from test1 it is necessary to pass the complete path in this case. ['/:Tmodelo/teste2'] in the link

    
10.07.2018 / 18:26