4

I have a route like this

const pipelinesRoutes: Routes = [
  {
    path: ':type',
    component: CatalogComponent,
    canActivate: [LoggedInGuard],
    children: [
      {
        path: '',
        component: CatalogContentComponent,
      },
      {
        path: ':domain/:categoryId',
        component: CatalogContentComponent,
      },
    ],
  },
  { path: '', redirectTo: 'skills', canActivate: [LoggedInGuard] },
];

Here i want to redirect my app to skills(:type) if no type is provided , it works fine on start, but once i refresh say having this url.

catalog/skills/technical

it redirect to

catalog/skills/skills/technical
4
  • Not working tried pathMatch prefix/full Commented Mar 30, 2021 at 6:11
  • Please explain what is the purpose of :domain and :categoryId Commented Mar 31, 2021 at 5:57
  • 1
    In catalog/skills/technical if skills is the :type then there is no path match for technical as it only accepts :domain/:categoyId Commented Mar 31, 2021 at 6:02
  • 1
    @T.SunilRao Yes that was the case. Commented Mar 31, 2021 at 7:32

1 Answer 1

1

Thanks T. Sunil Rao for helping me. Yes my route was having issue. I was passing empty param while routing with help of

this.router.navigate([domain, ''], { relativeTo: this.route });

But while refresh it doesn't treat that empty param as param so rediercting.

catalog/skills/technical doesn't full fill any route so it redirect to skills/ Correct route should be

const pipelinesRoutes: Routes = [
  { path: '', redirectTo: 'skills', pathMatch: 'full' },
  {
    path: ':type',
    component: CatalogComponent,
    canActivate: [LoggedInGuard],
    children: [
      {
        path: '',
        component: NoDomainContentComponent,
      },
      {
        path: ':domain',
        component: CatalogContentComponent,
        children: [
          {
            path: ':categoryId',
            component: CatalogContentComponent,
          },
        ]
      },
    ],
  },
];

Using child of another since i don't want to refresh the component, want to use same component and just filter the data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.