Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm working on an Angular app that uses Angular UI-Router for routing and maintaining state. I am having a hard time getting my unit test to even compile. It seems that no matter what I do, I keep getting the following error:

Error: State '' is not navigable

I have the following states set up in my app, as well as the following redirects:

app.config(function($stateProvider, $urlRouterProvider) {

var paramList = '?beds&lat&lon&zoom';

$urlRouterProvider
    .when('', '/')
    .when('/', '/search')
    .when('/search', '/search/list')
    .otherwise('');

$stateProvider
    .state('search', {
        abstract: true,
        url: '/search',
        templateUrl: 'views/search.html',
        controller: 'SearchCtrl'
     })
        .state('search.list', {
            url: '/list' + paramList,
            templateUrl: 'views/search-list.html'
         })
        .state('search.map', {
            url: '/map' + paramList,
            templateUrl: 'views/search-map.html'
        })
    .state('search.listing', {
        url: '/listing/:id' + paramList,
        templateUrl: 'views/search-listing.html'
    })
    .state('favorites', {
        url: '/favorites',
        templateUrl: 'views/favorites.html'
    })
});

I've eaten up an entire day trying to get a single test to work, but no matter what approach I take, I always end up at this same error. I have an e2e test running just fine.

share|improve this question

1 Answer

At first glance I would say it looks like the $stateProvider is telling you you need to put an empty state in there. Add this to the list of states.

state( '', { ... } )
share|improve this answer
I tried this, and the error I get now is Uncaught Error: State ''' is already defined from app. – davitykale 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.