I am trying to navigate to a another page by clicking a button but it fails to work. What could be the problem. I am now learning angular 2 and it\'s a bit tough for me now.
Follow these steps
Add import in your main component
import {Router } from '@angular/router';
In the same file add below code for constructor and method
constructor(private route: Router) {}
public Dashbord()
{
this.route.navigate(['/dashboard']);
}
This is your .html
file code
In app-routing.module.ts
file add dashboard
const routes: Routes =
[
{ path: '', pathMatch: 'full' ,component: TestComponent},
{ path: 'dashboard', component: DashboardComponent }
];
Good luck.