I want to render a link such as:
<a ui-sref="myState({myKey: 'my variable type value'})">
where state name myState
and key myKey
are variables.
Is there a way to accomplish this?
I want to render a link such as:
<a ui-sref="myState({myKey: 'my variable type value'})">
where state name myState
and key myKey
are variables.
Is there a way to accomplish this?
I found myself in the same situation, I couldn't acomplish that as well, try to move your code using ng-click and inside of your ng-click function use a $stage.go and pass the parameters there, something like:
Dynamic
ui-sref
is not supported, but I found an advice on using the generation of the link with the href method of the $state service:I think the simplest solution is
where vm.key is the value being passed from the controller. This avoids extra javascript as used in the answer for this. Its very similar to the accepted answer but the variable is used into the html tag as is, without creating a handler.
Actually I found a solution, so hopefully it will still help someone.
In my case I am using ui-router 1.0.15, so not sure if it will work with something older than v1.0.x
document({ id: document.id})
If your state is document/:id
How to pass parameters using ui-sref in ui-router to controller
Similar question was asked here. His solution was to set up a state that does the routing and you pass params to that state through ui-sref that triggers the desired URL