I have PageComponent
which data is renewed on different url (by using PageService
). It uses same PageComponent
object. I want that PageComponent
would be new object on new url.
PageComponent
on different url? const routes: Routes = [
{path: ':uri', component: PageComponent}
];
IF you are using angular 2 routing then there will be an index.html page and the component will be changed depending on the path in the URL.
For Ex.
RouterModule.forRoot([
{ path: 'heroes', component: HeroesComponent},
{ path: 'details', component: HeroesDetailComponent}
])
It will load HeroesComponent when URL will be /heroes
at place of
<router-outlet>
in index.html page and when URL will be /details
then it will load HeroesDetailComponent
at the place of <router-outlet>
.
For detail, you can read below URL
https://angular.io/docs/ts/latest/tutorial/toh-pt5.html