In angular2 how do you navigate to another route that requires an id?
I'm using this router version: "@angular/router": "2.0.0-rc.1"
This is my app.component route I want to navigate to:
{ path: '/blog/:slug', component: BlogArticle, as: 'BlogArticle' }
This is my other component trying to navigate to it:
this.router.navigate(['blog', { slug: blogId }]);
Basically I want to know how to navigate to a url with an id from the component and in a view.
Current attempt in the view:
[routerLink]=" ['/blog', {slug: blogId }]"
Current attempt in the component:
this.router.navigate(['blog', { slug: blogId }]);
Both attempts above didnt work and I got the following error:
Error: Uncaught (in promise): Cannot match any routes.
Its strange because I set my route link this in my app.component:
@Routes([
{ path: '/blog/:slug', component: BlogArticle, as: 'BlogArticle' }
])
as: 'BlogArticle'
from Route definition, it might be wrong syntax with RC1 router. – Sasxa