The Basic Sample is created
The Source Code is Uploaded Here
and Deployed Here
this.route.navigate(['/products']
) in "app.component.ts" navigates
to this 'home'.This is basic but weird, where have I gone wrong ?
It's getting redirected on your app.component.html
on line 19:
<a class="nav-link" href="#" (click)="navigateBack()"> Products(navigated in Component)</a>
This tag has href="#"
so the page is getting routed to your root because your app-routing.module.ts
file is redirecting to home.
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: '**', redirectTo: 'home', pathMatch: 'full' }
So, remove href="#"
with [routerLink]="[]"
and it should resolve the issue.