Ui Router is not adding #/ to URL on load

I'm using Angular UI Router in my project.

I've set it up and everything works fine. Except, I need to explicitly hit localhost:8000/#/ for my project to load.

When I was using ngRoutes, no such issue was faced.

My config is as follows:

app.config(function($stateProvider,$urlRouterProvider, $locationProvider){
    $urlRouterProvider.otherwise('/');
    $stateProvider.state('index',{
        url: '/',
        templateUrl: '/testassets/partials/index.html',
        controller: 'indexCtrl'
    })
});

How do I get the url hashPrefix to auto add to the url?

Try using this code for adding #/ on first load or whenever index page

app.config(function($stateProvider,$urlRouterProvider){
    $urlRouterProvider.when('', '/');
    $stateProvider.state('/', {
        url: '/',
        templateUrl: '/testassets/partials/index.html',
        controller: 'indexCtrl'
     })
});

Instead if you want to include template at index you can use without adding #/

app.config(function ($stateProvider) {
    $stateProvider.state('index', {
        url: '',
        templateUrl: '/testassets/partials/index.html',
        controller: 'indexCtrl'
     })
});