angular ui router - $urlRouterProvider.otherwise has empty $location.search() -
i've defined states , want use fallback state/url defined otherwise
. because states not define root url '/' (i have no view state) app may started url optional query params, tried use function call of otherwise
keep possibly given params. when otherwise
function called, $location.search()
empty, although url looks localhost:9002/?ac=1
.
maybe side effect given url rewritten localhost:9002/?ac=1#/search
although expect url rewritten localhost:9002/#/search?ac=1
.
$urlrouterprovider.otherwise(function($injector, $location) { var state = $injector.get('$state'); console.log('location', $location, 'location.search()', $location.search()); state.go('search', $location.search()); return $location.path(); }); $stateprovider .state('search', { url: '/search', templateurl: 'templates/search.html' }) .state('displays', { url: '/displays', templateurl: 'templates/displays.html' }) .state('favorites', { url: '/favorites', templateurl: 'templates/favorites.html' }) .state('detail', { url: '/:id', templateurl: 'templates/detail.html', controller: 'detailcontroller' });
is real error of ui-router or handling use case wrong way?
note i'm not using html5mode. "must have" use case?
i'm not sure if topic fits source of problem, please let me know if i'm wrong.
thanks, dennis
it might easier this: $urlrouterprovider.otherwise('', 'search');
Comments
Post a Comment