4

This should be simple, but I am not finding the right solution anywhere.

// Routing file
    ...
    .when('/pathA', templateA)
    .when('/pathB', templateB)
    .otherwise({ redirectTo: '/lollz' });

Both paths have a bunch of optional query parameters. The pages work when there are no parameters, but every time I pass a parameter, the router lands on the page /lollz. How can I make the router ignore the query parameters and concentrate only on the sub-paths?

9
  • How are you passing the query parameters? Commented Jan 14, 2016 at 5:27
  • Sample uri : /pathA?param1=1111 Commented Jan 14, 2016 at 5:28
  • Could you create a fiddle for this? Commented Jan 14, 2016 at 5:33
  • 1
    Try .when('/pathA:query', templateA) to return the query parameters. Commented Jan 14, 2016 at 8:29
  • 1
    So by using /pathA:query, you were able to see that the question mark ? had gotten mangled. I am glad that helped you debug the problem. Commented Jan 14, 2016 at 9:30

1 Answer 1

1

The issue was somewhere else, I made the mistake of passing query parameters to the $location.path like:

$location.path('/pathA?param1=aaa'); // which kept getting encoded into /pathA%3Fparams1=aaa

once I started passing the query params in chained search , the problem went away:

$location.path('/pathA').search({params1:'aaa'});
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.