ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

$state.go('^') should transition to first non-abstract parent state

Open g00fy- opened this issue 12 years ago • 12 comments

Whereas $state.transitionTo('^') should stay as it is (throws an exception).

Naive implementation is very easy:

$state.go = function go(to, params, options) {
      // special case
      if(to==='^'){
        to = $state.$current;
        do{
          to = to.parent;
        }while(to.abstract)
      }
      return this.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options));
    };

But wouldn't that be somehow inconsistent with the rest ?

g00fy- avatar Dec 13 '13 16:12 g00fy-

+1

mlegenhausen avatar Jan 21 '14 13:01 mlegenhausen

If it is consistent add a parameter, but this would make the implementation of a back method really easy.

mlegenhausen avatar Jan 21 '14 13:01 mlegenhausen

yeah maybe a transition option closestNavigable, where, if set to true, will allow navigating to abstract states without throwing an error if they have a navigable ancestor (and maybe also child?).

timkindberg avatar Jan 21 '14 18:01 timkindberg

+1

nihique avatar Nov 18 '14 20:11 nihique

+1

pzaich avatar Dec 17 '14 06:12 pzaich

+1

jonniedarko avatar Dec 23 '14 11:12 jonniedarko

+1

lrajlich avatar May 14 '15 00:05 lrajlich

+1

ccemeraldeyes avatar Aug 03 '15 19:08 ccemeraldeyes

+1

maxmarkus avatar Mar 30 '16 14:03 maxmarkus

+1

vlio20 avatar Jun 24 '16 18:06 vlio20

Closing this really old issue. I don't think we should change the semantics of what "^" means (parent state).

The closest navigable parent can be found at

$uiRouter.globals.$current.parent.navigable

christopherthielen avatar May 03 '17 17:05 christopherthielen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.

stale[bot] avatar Jan 24 '20 07:01 stale[bot]