On all of the examples that I see for the new component router the ID is always at the end of the route like this:
@RouteConfig([
{path: '/email/:id', component: email, as: 'email'},
])
Which you would need a router-link like this to access it:
<a [router-link] = "['./email', {id:1234}">Emails</a>
My question is, how would I write my router-link if my route had the following format?
@RouteConfig([
{path: '/user/:id/messages', component: email, as: 'email'},
])
When I manually type '/user/1234/messages' into my address bar I can successfully get to the page. But I can't seem to figure out the router-link format that will do the same thing.
@brandonroberts answered this question HERE. Basically, the router-link will try to find the route by it's name.
@RouteConfig([
{path: '/user/:id/messages', component: email, as: 'Email'},
])
So in the example above the name is Email. So the router link-would have to be written like this:
<a [router-link] = "['./Email', {id:1234}">Emails</a>
So router-link will look for a route named "Email" and once it finds it, it will fill in the parameters.
Thanks Brandon for the help!