This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
add $locationProvider.baseHref() #2805
Closed
Description
Running an Angular app in a subdirectory is painful. All your routes, resources, locations, etc etc have to be manually prefixed with the application context. Example:
$routeProvider.when(root + 'path', {templateUrl: root +'path/file.html', controller: 'SomeCtrl'});
//and
$location.path(root + 'somepath');
//and
return $resource(root + 'some/resource/:id', {id: '@id'});
It's annoying and also error prone if your development env runs in a subdirectory (pretty common).
One current solution is to add a <base href="/myroot/">
tag to the document. This solves the problems from the Angular perspective but causes many issues of its own, especially for third-party libs/widgets that use anchors.
The ideal would be to make $location configurable with a base path, much like Backbone router's root
config.
$locationProvider.baseHref = "/myroot/";
$location.path('/awesome'); // goes to /myroot/awesome
$routeProvider.when('/mypath', ...); //matched at /myroot/mypath
$resource('/some/resource'); //maps to /myroot/some/resource
This change would make running Angular in different contexts much easier.
Metadata
Metadata
Assignees
Labels
No labels