Tampa
Tampa

Reputation: 78294

RouterLink- angular2, child route and a query string

angular2,

How do I add a query query to a nested route in this format?

This works in ts file:

routerLink = ['/output', {outlets: {'output': ['details']}}] 

http://localhost:4200/#/output/(output:details)

How do I modify to add a query parm? URL should like like this:

    http://localhost:4200/#/output/(output:details;id=1)

Upvotes: 0

Views: 217

Answers (1)

Max Koretskyi
Max Koretskyi

Reputation: 105497

You can pass parameters as objects to URL segments like this:

router.navigate([
     '/inbox', 33, {details: true}, 'messages', 44, {mode: 'preview'}
])

So in your case it will like this:

routerLink = ['/output', {outlets: {'output': ['details', {id: 1}]}}] 
                                                           ^^^^^

this will generate the URL:

/output/(output:details;id=1)

Upvotes: 1

Related Questions