Description
I would say, that the _"fix"_ in 0.2.13, related to: Avoid re-synchronizing from url after .transitionTo, change: 19715d15 introduced a new issue. Or at least, the .when('/parent', '/parent/child')
is not working for ui-sref="parent"
Description of the "issue"
As documented here: How to: Set up a default/index child state small extract:
Or if you want the 'parent.index' url to be non-empty, then set up a redirect in your module.config using $urlRouterProvider:
$urlRouterProvider.when('/parent', '/parent/index');
$stateProvider
.state('parent', {url: '/parent', abstract: true, template: '<ui-view/>'} )
// url '/parent/index'
.state('parent.index', {url: '/index'} )
NOTE: in the above cite, I replaced the home
in url with parent
to make it more consistent
This has stopped working. There are plunkers:
Examples
There are examples of the issue with different versions:
- working with version 0.2.12
- not working with version 0.2.13
- working with rolled back version 0.2.13 - if commented out the fix mentioned above
this is the change applied in "roll back" of a fix 19715d15 0.2.13 inside of the released angular-ui-router.js
1988 ...
1989 // RKö - rollback of a fix
1990 // if (ignoreUpdate) return true;
1991 ...
Workaround without change of 0.2.13
I described how to go around here Angular UI-Router $urlRouterProvider .when not working when I click <a ui-sref=“…”>
, we need eventing:
var onChangeConfig = ['$rootScope', '$state',
function ($rootScope, $state) {
$rootScope.$on('$stateChangeStart', function (event, toState) {
if (toState.name === "parent") {
event.preventDefault();
$state.go('parent.index');
}
});
}]
Maybe this is the way to go (or please, give me better). But as mentioned below, not sure about consistency...
Question, is it an issue? or not
I can imagine that this issue would be refuesd as proper behaviour.
BUT, is it really what we want - if this will result in 2 different states:
<a ui-sref="parent"> // goes to parent
<a href="#/parent"> // goes to parent.index