The Angular Router is just not meant for that (yet). Try the UI Router it will do what you are expecting.
AngularJS Multi-Level Default Routes
-
28-06-2023 - |
Question
In AngularJS, I wanted to send all my routes to a single controller - so I figured - why set up routing at all?
It seems simpler to get route information with $window.location.pathname.split("/");
At first, this looked like a good plan:
- 'mysite.com' worked
- 'mysite.com/' worked
- 'mysite.com/home' worked
But when I try to do a 2-level or a 3-level route:
- 'mysite.com/team/my-name'
- 'mysite.com/blog/post/my-post'
Angular crashes saying:
Uncaught SyntaxError: Unexpected token <
Why isn't Angular default routing OK with multi-level routes?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow