Mike Mike - 2 years ago 172
AngularJS Question

Components navigate route

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 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'}


Answer Source

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().

Plunker example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download