-
Notifications
You must be signed in to change notification settings - Fork 3k
A reverse function that generates URI string from state name and params? #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
AFAIK this should work: |
Thanks for reply. I dont want an instant state transition, but invoking this to generate links. For example: $scope.getFooLink = function() {
return $state.reverse('foo', {fooId: some_var});
}; and in view <a ng-href="{{ getFooLink() }}">foo</a> |
Arh, then it's related to #16 instead i suppose |
Yes, that's essentially #16, but I agree it makes sense to have both a function and a directive (presumably the directive would just be a wrapper around the function). |
It would be nice to have a reverse function in
$state
to map state name and params to corresponding URI. For example:then
$state.reverse('foo.bar', {fooId:1, barId:2})
generates URI string:'/1/2'
(or'#/1/2'
, depends onhtml5mode
)Currently, this could be done by using
$state.$current.url.format
for the current state or ancestor states, but not for the other such as sibling states. Comparing with concatenating strings, this way feels neat and better managed.The text was updated successfully, but these errors were encountered: