I searched a lot in stackoverflow and web regarding this and no where I got a straight answer to my question. Hence requesting for help. Here is my problem:
I enabled 'html5mode' in my angular js application to remove the '#' symbol from the URL. After enabling I am successfully able to remove the hash from URL but I am getting it like (running my application in tomcat)
localhost:8080/resources/list/abc
I am expecting something like
localhost:8080/my-app-context/resources/list/abc
I have added base tag in my index.html too like the following ways
<base href="/" />
<base href="my-context-path" />
but neither worked.
Moreover after enabling html5 mode, i lost relative lookup for files in the templateUrl
Here is my code
resourcesModule.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.when('/resources', '/resources/listView/kristin');
$urlRouterProvider.when('', '/resources/list/abc');
$urlRouterProvider.otherwise('/resources/list/abc');
$stateProvider.state('apptemplates', {
url: '/apptemplates',
templateUrl: 'templates/templates.html',
controller: 'TemplatesNavigationController'
})
.state('home', {
templateUrl: 'my-context-path/home/home.html',
controller: 'ResourceManagerController'
})
.state('home.resources', {
url: '/resources',
templateUrl: 'my-context-path/resources/resources.html',
controller: 'ResourcesController'
})
.state('home.resources.listview', {
url: '/listView/{roleID}',
templateUrl: 'resourcemanager-ui/resources/listview/listview.html',
controller: 'ListViewController'
});
$locationProvider.html5Mode(true);
}]);
One more queston. Earlier when html5 mode wasn't enabled, it was mapped to
$urlRouterProvider.when('', '/resources/listView/kristin');
but after enablng html5 mode it was always routing to 'Otherwise". Any specific reason.
Thanks in advance