Coder Social home page Coder Social logo

Comments (7)

christopherthielen avatar christopherthielen commented on May 17, 2024

deepStateRedirect can now be a function.

I haven't added tests yet. I built off the dev branch if you want to try this:
https://gist.github.com/christopherthielen/40d33f98ddf2e4ffde04

example:

 $stateProvider.state({
    sticky: true,
    deepStateRedirect: function($state) { return !$state.includes(this.name); },

from ui-router-extras.

jeverden avatar jeverden commented on May 17, 2024

Awesome thanks. I'll give this a shot soon.

from ui-router-extras.

appagg avatar appagg commented on May 17, 2024

I am facing the exact problem as jeverden mentioned. I am using deepStateRedirect. Just added breadcrumbs to my states and clicking the parent breadcrumbs from the child state/view won't return back to the parent state/view. How's the deepStateRedirect function going to help in this situation?

from ui-router-extras.

appagg avatar appagg commented on May 17, 2024

Ah, I think I got it. Added this to the parent state: deepStateRedirect: function($state) { return !$state.includes(parent_state_name); }, Not fully understand how it works though. :)

Another thing, it seems that I have use the dot notation for the deepStateRedirect to work, it won't work if I use the parent attribute instead of the dot notation.

from ui-router-extras.

moosi avatar moosi commented on May 17, 2024

I want to use this feature as well, but have the following situation:

  1. Tab clicked first time -> go to default state "feed"
  2. Tab clicked later on again -> dsr to the last active state
  3. Tab clicked twice -> go to default state "feed"

When using the dsr object for the definition there is a property "default" to set a default state but how can I realise this using a dsr function for the definition?

from ui-router-extras.

moosi avatar moosi commented on May 17, 2024

I got it running by adapting the example of the homepage

deepStateRedirect: {
        default: { state: "foo.bar.baz.defaultSubState", params: { defaultStateParam1: "99" } },
        params: true,
        fn: function($dsr$) {
            var shouldRedirect = // TODO finish docs;
        }
}

In this example the current state was missing to be able to realise my use case (since $dsr$ only contains the "to" and "redirectTo" state). Then I noticed thats it's possible to simply inject the $state parameter:

deepStateRedirect: {
      default: { state: 'home.feed.list' },
      fn: function($state) {
        return $state.includes('home.feed.*') ? {state: 'home.feed.list'} : true;
      }
}

from ui-router-extras.

bluegreenapple avatar bluegreenapple commented on May 17, 2024

Hi, I did as mentioned with my tabbed app

$stateProvider.state({
sticky: true,
deepStateRedirect: function($state) { return !$state.includes(this.name); },

and it works so that I can go back from the sticky state substate (child) back to the stick state (parent), however, it introduces another bug. As soon as click on the sticky states' tab I get the following error:

RangeError: Maximum call stack size exceeded
at Object.extend (angular.js:455)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)
at $injector.invoke (ct-ui-router-extras.js:1662)(anonymous function) @ angular.js:12221(anonymous function) @ angular.js:9055Scope.$broadcast @ angular.js:16040transitionTo @ angular-ui-router.js:3229$state.transitionTo @ ct-ui-router-extras.js:208$state.transitionTo @ ct-ui-router-extras.js:1713$state.transitionTo @ ct-ui-router-extras.js:1191go @ angular-ui-router.js:3068(anonymous function) @ ct-ui-router-extras.js:312Scope.$broadcast @ angular.js:16038transitionTo @ angular-ui-router.js:3229$state.transitionTo @ ct-ui-router-extras.js:208$state.transitionTo @ ct-ui-router-extras.js:1713$state.transitionTo @ ct-ui-router-extras.js:1191go @ angular-ui-router.js:3068(anonymous function) @ ct-ui-router-extras.js:312Scope.$broadcast @ angular.js:16038transitionTo @ angular-ui-router.js:3229$state.transitionTo @ ct-ui-router-extras.js:208 ...

any thoughts on how to solve that?

from ui-router-extras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.