I am currently using AngularJS with UI-Router for state management and express on the back-end.
I currently have hash bang mode enabled and have been trying to find a solution that allows you type URL's without the hash bang manually in the address bar.
So for example instead of typing:
www.mysite.com/#!/page1
I want to able to type
www.mysite.com/page1
I have tried by enable html5Mode:
$locationProvider.html5Mode(true)
.hashPrefix('!');
But it still doesn't work. With the above change, clicking any URL's will re-write and change location from '#!/page1' to '/page1'. Which is great.
However manually entering a URL with '/page1' does not work and gives an invalid path error. If I type it with hash bang included i.e. '#!/page1' then it works and also re-writes the URL as the '/page1' after page load.
So what am I doing wrong here?
My states look like this:
state('login', {
url: '/login',
templateUrl: 'login.html'
}).
state('parent', {
url: '/hello',
abstract: true,
template: '<ui-view/>'
}).
state('parent.home', {
url: '',
controller: 'SomeCtrl',
templateUrl: 'page.html'
}).
state('parent.file', {
url: '/bob',
controller: 'SomeCtrl2',
templateUrl: 'file.html'
})