I have a very similar scenario to the angular-ui-router demo app: whenever the user tries to access a state that requires auth, there's a hook which redirects him to the login state. The additional requirement is that someone might want to access a state via URL with an additional querystring parameter: username
which should be auto-populated in the login page's corresponding input.
My states structure is like so:
- there is a
shell
abstract state which is parent to all other states similar to theapp
state in the demo app - this
shell
state hasurl: '?username'
(if I understand correctly this parameter should then be inherited by all other states) - my
login
component has a bindingusername: '<'
- the
login
state has aresolve
like sousername: $transition$ => $transition$.params().username
The whole login/redirect mechanism works perfectly. The only problem is that in the login
's state resolve
the params().username
is undefined even if in the browser I go to a link like http://mysite/#/somestate?username=foo
.
Any idea what I'm doing wrong or how I can achieve what I'm after?
Thanks!