1

I'm trying to create a route config that will match the path :id/compA, otherwise fallback to the route that has the :tab route parameter. The :tab route always seems to match regardless of order.

How do I do this?

Thanks!

const routes: Routes = [
    {
        path: ':id/compA',
        component: SpecificComponent
    },
    {
        path: ':id/:tab',
        component: GeneralComponent
    }
];
2
  • Angular by default looks at parameterised routes first and then non parameterised ones. So :id/:tab takes precedence over the other one. I guess you might wanna redesign your routes and components. But anyway, 2 consecutive parameters in the routes don't look like a good idea. Commented Jan 10, 2020 at 0:45
  • Thanks for the info. I agree that I should take another approach here with my path matching. Commented Jan 10, 2020 at 13:58

1 Answer 1

3

You could try giving UrlMatcher a try.

You could setup some custom logic for route matching.

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.