Daughter Routes, Angular 5

Asked

Viewed 703 times

0

I have a Component, where it receives only one parameter in its route, this way below:

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

This Commission, in turn, has 3 daughter 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 am having difficulty accessing the route 'teste2', by the 'teste1' route Component, that is, in my Component teste1.html I have the following call:

[routerLink]="['teste2']"

and the following error is presented:

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

This error does not happen if I do the same button in the 'Basenumerica' system. What should I do?

  • William this happens by just passing test2 he understands that you intend to access a level above the current. That’s why from Basenumerica you access the teste2 without problems passing only it. To access from the teste1 you need to pass the full path in this case. ['/:model/teste2'] at the link

1 answer

1


William this happens by just passing test2 he understands that you intend to access a level above the current. That’s why from Basenumerica you access the teste2 without problems passing only it. To access from the teste1 you need to pass the full path in this case. ['/:Tmodelo/teste2'] on the link

  • I got it. But I did the test here and this error is shown 'Error: Cannot match any Routes. URL Segment: ':Tmodel/teste2''

  • o :Tmodel should not be replaced by /modelo and deoius completed with the /teste2/ only? Technically when you were in the teste1 he directed to modelo/teste1/teste2 , and if the test 1 and test 2 are at the same level I think it would be /modelo/teste2/

  • Ok. worked rs, value! This model is a parameter, I can get the string of this parameter?

  • We can pick up using SNAPSHOT: snapshot.parent.params['model']

  • Thanks was nothing. :)

Browser other questions tagged

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