Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
// Register the state in the global state list and with $urlRouter if necessary.
if (!state['abstract'] && url) {
$urlRouterProvider.when(url, ['$match', function ($match) {
$state.transitionTo(state, $match, false);
if ($state.$current.navigable != state) $state.transitionTo(state, $match, false);
}]);
}
states[name] = state;
Expand Down
10 changes: 8 additions & 2 deletions test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ describe('state', function () {
.state('home.item', { url: "front/:id" })
.state('about', { url: "/about" })
.state('about.person', { url: "/:person" })
.state('about.person.item', { url: "/:id" });
.state('about.person.item', { url: "/:id" })
.state('about.sidebar', {});

$provide.value('AppInjectable', AppInjectable);
}));
Expand Down Expand Up @@ -160,7 +161,7 @@ describe('state', function () {
'$stateChangeSuccess(C,A);');
}));

it('aborts pending transitions even when going back to the curren state', inject(function ($state, $q) {
it('aborts pending transitions even when going back to the current state', inject(function ($state, $q) {
initStateTo(A);
logEvents = true;

Expand Down Expand Up @@ -191,6 +192,11 @@ describe('state', function () {
'D.onExit;' +
'A.onEnter;');
}));

it('doesn\'t transition to parent state when child has no URL', inject(function ($state, $q) {
$state.transitionTo('about.sidebar'); $q.flush();
expect($state.current.name).toEqual('about.sidebar');
}));
});


Expand Down