christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

dsr - pass params to 'default' transition #255

Closed dmaciaszek closed 8 years ago

dmaciaszek commented 8 years ago

Hi I have two states:

state('main.test0', {
      url: 'tabs',
      views: {
        //my views
        },
      dsr: {default : 'main.test0.person'}
      sticky: true
  }

and

state('main.test0.person, {
      url: 'view/person/{id:int}',
      views: {
        //my views
        }
 }

When I go to 'main.test0' I want to redirect to 'main.test0.person'. It is realized by 'default' name in dsr (defined in 'main.test0' state) but 'main.test0.person' state take url parameter {id:int} and I have no idea what I pass this parameter to it. I try do like: Add to dsr definition some params so my state definition look that:

state('main.test0', {
      url: 'tabs',
      views: {
        //my views
        },
      dsr: {default : 'main.test0.person', params:{id: 'myId'}},
      sticky: true
  }

and $state.go('main.test0', {id:'myId'}); But it is not working...I got error:

TypeError: dsrParams.sort is not a function
    at getMatchParams (ct-ui-router-extras.dsr.js:108)
    at getParamsString (ct-ui-router-extras.dsr.js:113)```
I think I do something wrong.

To sum app...I need to pass to 'main.test0.person' some id. (see url : 'view/person/{id:int}') but I want to go to this state by redirect ('deafult' transition) from state 'main.test0'. So I want to do it by:
$state.go('main.test0', {id:myId});
Could you give me some tips how I do it?
christopherthielen commented 8 years ago

read the example again for the "default" property: http://christopherthielen.github.io/ui-router-extras/#/dsr it should be

dsr: { 
  default: { state:''main.test0.person', params: {id: 'myId'} }
}