How to naviage to another component from current component? I have tried like this:
account component:
vm.$onInit = function () {
var jwt = accountService.getJWT();
if (!jwt || jwtHelper.isTokenExpired(jwt)) {
this.$router.navigate(['registration']);
}
};
This doesn't work for me :(
Component "Root" has no route config.
I have set $routerRootComponent
.value('$routerRootComponent', 'app')
.component('app', {
template: '<ng-outlet></ng-outlet>',
$routeConfig: [
{path: '/registration', component: 'registration', useAsDefault: true},
{path: '/registration/:referrer', component: 'registration'},
{path: '/account', component: 'account'}
]
})
Routes (in the old router) need a name and router.navigate()
expects the name to be used, otherwise you would need to use for example router.navigateByUrl()
.