The Angular $routeProvider can only change the part of the URL after the hash (#
), so when calling $location.path()
, you just use a plain URL fragment like you defined in the route for DamageCtrl
.
Some explanation
I'm going to simplify a bit here, but hopefully it will help you understand what's going on.
You're making a SPA (single-page app), so the URL you enter in your browser to get into your app doesn't change while you navigate between routes; by default $routingProvider appends #/whatever/route
to that base URL. In your case it looks like you have your entry point (ng-app
) in a file called /windscreens/glass/index
, so all routes will get appended to that.
Because you don't have an /index
route defined that we can see, I'm not sure how http://localhost/windscreens/glass/index#/index
is working for you. It should send you to http://localhost/windscreens/glass/index#/
because your otherwise
route is just /
.
Back to the question
If I understand your question correctly, I would make the index file (where ng-app
lives) /windscreens/glass/index.html
, then you can just enter http://localhost/windscreens/glass/
to get into the app, because the webserver will serve the contents of index.html by default.
At that point, your index page URL would become http://localhost/windscreens/glass/#/
, and your /booking/damage/
routes would be http://localhost/windscreens/glass/#/booking/damage/ABC
etc. The code to navigate to them would then be
$location.path('/booking/damage');