Reputation: 205
I have states like this:
.state('portfolio.work1', {
url: '/work1',
templateUrl: 'app/portfolio/work1.html'
})
.state('portfolio.work2', {
url: '/work2',
templateUrl: 'app/portfolio/work2.html'
})
I want to set dynamic value of ui-sref like this:
<a ui-sref="{{ data.nextLink }}">
where data.nextLink
is example '.work2'.
Interpolation not working with ui-sref
. How can I do this?
Upvotes: 1
Views: 321
Reputation: 6033
You can use a function instead of ui-sref
<a href='#' ng-click='goToNextLink(data.nextLink)'>
and define goToNextLink(...)
in the controller (you need to inject the dependencies on $state
and $scope
):
$scope.goToNextLink = function(link) {
$state.go(link);
}
See the documentation for $state.
Upvotes: 1