I have a problem that seems simple, but I've searched a lot for the solution but couldn't find it, especially since lots of things changed since Angular2.
I have few special pages
/page/1
represents page about water
/page/2
represents page about fire.
Other pages are "normal" like
/contact
/about
...
In RouterModule I have:
RouterModule.forRoot([
{
path: 'page/:id',
component: PageComponent
},
{
path: 'contact',
component: ContactComponent
},
So Water and Fire content are generated in PageComponent depending on id 1 or 2, respectively. (I have other dynamic data, not just water and fire)
Now I want when user enters
/water
to see the content of (without changing URL!) to
/page/1
So I have a redirection, in lack of better solution:
{ path: 'water', redirectTo: 'page/1', pathMatch: 'full' },
{ path: 'fire', redirectTo: 'page/2', pathMatch: 'full' } ...
But that results in changing URL. But what I want is when user enters
/water
I want the URL to remain that, not the redirection! (Same goes for /fire and other dynamic content pages.)
/pages/:idroutes, and have{ path: 'water', component: PageComponent }?ActivatedRoute.params(orparamMap) is there for a reason.