After reading up as much as I could on this topic, and making sure to keep in mind Angular's 'zen' rules, I'd like to suggest a small addition to the $location service.
Before I make any changes to the framework's code I'd like to see what the community thinks.
My one page app resides on a page that's not the root of the site (
www.domain.com/onepageapp). In order to avoid including the name of my page in all my route definitions I added the <base href="/onepageapp/" /> tag to the head of the html as it seems to be the accepted solution.
Everything worked wonderfully, but then I decided to add an in-page anchor (<a href="#anchor" />). That's when I realized that the <base> tag also changes the
relative path of every link on the page (link was changed to '
domain.com/#anchor' instead of '
domain.com/onepageapp#anchor').
Shouldn't there be a way to modify Angular's base path without having to put up with the extra behavior of the <base> tag?
I suggest adding a way to set the location's base url manually like so:
angular.config(function () {
$locationProvider.baseHref('/my/nested/base/path');
});
What do you guys think? Is there an obvious implication I haven't considered?