0

I have seen this: https://stackoverflow.com/a/38038733/806963 but I cant find a way to add params from the navigateByUrl method or a way to acomplish any of that in Angular2 final.

I have 2 router-outlers in 2 diffrent components.

  1. <router-outlet></router-outlet> inside AppModule.
  2. <router-outlet name="account-information-outlet"></router-outlet> inside AccountModule.

My code:

export const appRouting = RouterModule.forRoot(
  [
    {
      path: 'shop',
      loadChildren: 'app/modules/shop.module#ShopModule'(is not imporntent right now)
    },
    {
      path: 'account',
      loadChildren: 'app/modules/account.module#AccountModule' (related to the code below)
    },
    {
      path: '',
      redirectTo: 'shop',
      pathMatch: 'full'
    },
  ]);

export const accountRouting: ModuleWithProviders = RouterModule.forChild([
  {
    path: '',
    component: AccountInformationComponent,

    canActivate: [
      IsAnyUserLoggedInGuard
    ],
    children:[
      {
        path: 'profile/:key',
        component: ProfileComponent,
        outlet: "account-information-outlet"
      }
    ]
  }
]);

I tried to call this from AccountModule (AccountInformationComponent) : this.router.navigate(['account/profile', parameter) but it failed.

Error:

Cannot match any routes: 'account/profile/-KUOW06DpH06D2rdvbLJ'

Community
  • 1
  • 1
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
  • what error you get? and from where you are calling router.navigate method??? – micronyks Oct 28 '16 at 13:41
  • I added the error and where I called if from. (Thought i added it in the first place) – Stav Alfi Oct 28 '16 at 13:44
  • `account/profile` refers to sibling component of `AccountInformationComponent` which is not define. profile is your child route and not the parent route. – micronyks Oct 28 '16 at 13:44
  • `account/profile` refers to `ProfileComponent` with is defined. I'm sory I think that I'm not following. Can you explain it agian? – Stav Alfi Oct 28 '16 at 13:48

0 Answers0