I'm using ng-show
with an expression that resolves to a promise that resolves to a boolean. When I do this I get the 10 digest iterations overflow.
See http://plnkr.co/edit/XibYM0kCnXhKjNUeTsp3?p=preview
<body ng-controller="MainCtrl">
<p ng-show="returnsABoolean()">non promise</p>
<p ng-show="returnsAPromiseThatResolvesToABoolean()">promise</p>
</body>
Ctrl:
$scope.returnsABoolean = ()->
true
$scope.returnsAPromiseThatResolvesToABoolean = ()->
$q.when(false)
I know that {{somePromise}}
will resolve, but {{returnsAPromiseThatResolvesToABoolean()}}
seems to cause the same issue.
Any ideas? I'd expect this to work..
AngularJS resolves the promise for template binding automatically. However, you should use the promise in ng-init
to prevent the digest cycle from returning a new promise every tick.
<p ng-init="v=returnsAPromiseThatResolvesToABoolean()" ng-show="v">promise</p>
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