I have a weird problem , that when a particular route is directly launched the component is added twice in the dom, but when navigated from main page it works fine.
The problem is with contact
route ContactComponent
You can check that live on this website
- Go to http://ootybookings.in/#/main/contact
- You can see the contact component added twice
- Now click on Home Menu/Link at top and then Click Contact Menu/Link
- Now the duplicate is gone
All other routes are fine. Only contact route is making this problem.
Config
"@angular/animations": "^4.4.6",
"@angular/common": "^4.4.6",
"@angular/compiler": "^4.4.6",
"@angular/core": "^4.4.6",
"@angular/forms": "^4.4.6",
"@angular/http": "^4.4.6",
Routes
const routes: Routes = [
{
path: '',
redirectTo: 'welcome',
pathMatch: 'full'
},
{
path: 'welcome',
component: WelcomeComponent
},
{
path: 'home',
component: HomeComponent
},
{
path: 'main',
component: MainComponent,
children: [
{
path: '',
redirectTo: 'tour-packages',
pathMatch: 'full'
},
{
path: 'tour-packages',
component: TourPackagesComponent
},
{
path: 'tour-package/:name',
component: TourPackageDetailComponent
},
{
path: 'activities',
component: ActivitiesComponent
},
{
path: 'contact',
component: ContactComponent
},
{
path: 'who-we-are',
component: WhoWeAreComponent
},
{
path: 'why-ooty',
component: WhyOotyComponent
},
{
path: 'services',
component: TourServicesComponent
},
{
path: 'blogs',
component: BlogComponent
},
{
path: 'blog/:name',
component: BlogDetailComponent
},
{
path: 'offers',
component: OffersComponent
},
{
path: 'terms',
component: TermsComponent
},
{
path: 'privacy',
component: PrivacyPolicyComponent
},
{
path: 'refund',
component: RefundPolicyComponent
}
]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
How can I resolve this? Is there a problem with my routing module? I've checked similar questions on SO and other sites, but I cannot find a solution.