-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
I'm having the weirdest issue with ui-router. I've been using it for over a year now, so I know how to use it, but I'm encountering a strange issue now which I have not seen before.
My initial route won't load when I navigate my browser to / or /test (the routes are defined). Just a blank page is show. If I navigate to those routes programmatically though or via links (ui-sref='test'), it works and the proper route template shows up.
It's just not working for the initial page load.
The strange thing is, that I figured out how to "fix" it, but I have no clue why this fixes it or what is broken in the first place:
//Change this...
.run(function($rootScope, App) {
$rootScope.App = App;
});
//To this...
.run(function($rootScope, App, $state) {
$rootScope.App = App;
});Simply adding $state to the run function (not doing anything whatsoever with it) fixes the issue, and the correct route now shows up when refreshing the browser.
Has anyone else ever encountered this?
This is with ui-router 0.2.15 and angular 1.4.0.
Also tested with ui-router 0.2.13, same behaviour.
For good measure, these are my routes:
$stateProvider.state('home', {
url: '/',
templateUrl: 'home/home.html'
});
$stateProvider.state('test', {
url: '/test',
templateUrl: 'test/test.html'
});And config:
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/');