Refreshing browser web-page not load in ui-router when locationProvider used

36 Views Asked by At

When I directly refresh the browser using F5 or directly hitting the url, page not load but when I click on the button then the page gets load

I am using like this

Enable HTML5Mode using $locationProvider

var routerApp = angular.module('myApp', ['ui.router','ngCookies']);
routerApp.config(function($locationProvider){
    $locationProvider.html5Mode({
          enabled: true
    })
});

I Added the following code to the of your HTML file:

<base href="/">

or Simply using Syntax like that

$locationProvider.html5Mode({
          enabled: true,
          requireBase: false
    })

I find that this is already issue on https://github.com/angular-ui/ui-router/issues/105

Can someone knows how to solve this ? When I am not using $locationProvider for omitting '#' then it is working fine with refreshing too

2

There are 2 best solutions below

1
Joshua J Wilborn On

Try

$locationProvider.html5Mode({
    enabled: true,
    requireBase: false
})
1
AudioBubble On

Attempt this

$locationProvider.html5Mode({
    enabled: true,
    requireBase: false
})