I am facing a strange issue in Angular 2 route where I am able to route to next page ONLY but unable to route from that page.
I have 4 components: Home, Search Result, Profile and Admin.
When I first arrive to Home component, I can navigate to Search Result but from search result I cannot navigate to anywhere except to Home component.
The home component and app topbar contains the same logic (same code) and the topbar logic is working fine for all pages while navigation. i.e. when I naviate from any page to search result page from top bar button, I am able to navigate to next page and any other pages.
My Route:
{path: '', component: HomeComponent},
{path: 'seachresult', component: SearchResultComponent},
{path: ':code', component: ProfileComponent},
{path: 'admin/account', component: AdminComponent}
Here, in above HomeComponent, I tried the following:
- Replaced the '' by 'home'
{path: 'home', component: HomeComponent},
- Updated the route as below:
{path: '', redirectTo: 'home ', pathMatch: 'full'}, {path: 'home', component: HomeComponent},
- Redirected directly from the routerLink of button to search result page
None of above could solve the issue.
While click on search button, following code is executed:
this.router.navigate(['vendors', 'pokhara']);
Following are the version in package.json:
- "rxjs": "^5.2.0",
- "@angular/router": "^4.1.0",
app.component.html
– Exterminator