My issue was a bad path in my url:
Check the URL! http://example.com/#/
is not registered and $stateProvider won't tell you it's wrong.
I simply had to remove "/#/
" from my URL.
I suppose a hash got added on somewhere, but I had the same problem as OP: header and footer were fine, but nothing inside <ui-view></ui-view>
No idea why the devs would make it so that when you go to an unregistered path it gives no errors or indication of any kind that something bad happened, but there you go...
How to permanently fix this issue:
$stateProvider
overrides $urlProvider
, so .otherwise
won't work.
Add an otherwise
state:
/// OP's code ///
$stateProvider
.state('home',{
url:'/',
templateUrl:'home.html'
})
// Just add a new state
.state('otherwise',{
url:'*path', // uses regex, and doesn't mess up preceding state urls
templateUrl: 'home.html' // sends the user back home if a bad url happens
})
In response to using $rootScope
While @GlenFilson's answer did not provide any indication the path was incorrect, I was able to figure out where his answer should go:
var app = angular.module(...); // can't inject $rootScope here except through providers (e.g., $httpProvider)
app.config(...); // nor here
// define app.run() after configuration
app.run(function($rootScope){
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
$dialogs.error("Something went wrong!", error);
console.error("$stateChangeError: ", toState, error);
});
})