I have a problem with the router function "navigate", in my AppComponent I have :
@RouteConfig([
{path:'/home', name: 'Home', component: HomeComponent, useAsDefault: true, data: {user: null}},
{path:'/dashboard', name: 'Dashboard', component: DashboardComponent}
])
In my HomeComponent, I am trying to do this :
...
constructor(private _router:Router){}
changePage(){
this._router.parent.navigate(["Dashboard"]); // It fails
}
...
It doesn't send me at '/dashboard', is this normal ?
I have finally found ! It's working with :
changePage() {
this._router.navigate(["../Dashboard"]);
}
Thank you for helping me
why using parent ? it should be this._router.navigate(["Dashboard"]);
router.navigate is a method which take path as a parameter and navigate to that particular path and load component, I hope it will work.
constructor(private _router:Router){}
changePage(){
this._router.navigate(["dashboard"]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With