Is it possible to develop an Angular.js application in a way that would be abstracted from the the web directory path in which it will be deployed?
I am trying to put an Angular.js app in a web server subdirectory http://example.com/myproject/, but the router redirects me to the web server root -- http://example.com.
Below is my Angular.js app:
var myproject = angular.module('myproject', []);
myproject.config(function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {templateUrl: 'partials/index.html', controller: IndexCtrl}).
otherwise({redirectTo: '/'});
$locationProvider.html5Mode(true);
});
function IndexCtrl($scope, $location) {
}
Try setting a <base href="/sudirectory"/>
in your <head></head>
. That's what I needed to do to get mine working, IIRC
Word of caution: This will mess with any anchor tags that have href="#", as well as act as the root for image srcs and the like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With