Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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

share|improve this question

1 Answer 1

My bad, after adding the base tag as follows, things are working fine

 <base href="/my-context-path/" />

Even relative lookup is working fine

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.