I am doing ng-repeat of a list that look like this:
<div ng-repeat="x in myCtrl.data" ui-sref="app.detail({id: x.id})">
<img ng-src="{{::x.image}}">
<h2>{{::x.name | characters:35}}</h2>
</div>
When I monitor the watcher, I found that the watcher increases when the list getting longer. If I remove the {id: x.id} from the ui-sref, no matter how long the list is, the number of watcher always remains the same.
So, my question is how can I do a single binding in ui-sref?
ui-sref="app.detail(::{id: x.id})
no redirects nothing, one line code one time binding
Yes, if you look at API you will come to know that, it adds watcher from this line & you can't avoid that.
You could get rid of that watcher by do the redirection to state thing by your own, like you could have ng-click="redirect('app.detail', {id: x.id})" event there instead of having ui-sref directive, and from redirect method you could redirect to the state using $state.go.
Code
$scope.redirect = function(stateName, param){
$state.go(stateName, param)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With