The problem:
Using angularjs 1.3.0 beta 15, I'm trying to "bindonce" to a property of an object that is fetched from a server:
<div ng-if="::(myObject.foo === 'bar')"></div>
if myObject is not yet fetched (its promise is not resolved) in the time this html is loaded, angular evaluates the expression as false (no matter the value of course), and stops watching it.
Possible workarounds that I'd rather avoid:
:: solves this of course - not an option (performance-wise)foo with isFooEqualsBar, that gets its value when myObject is resolved (and binding to ::isFooEqualsBar) - it requires a lot of new properties just for thatIs it a bug? or am I using the :: syntax wrong?
One-time expressions will stop recalculating once they are stable, which happens after the first digest if the expression result is a non-undefined value (see value stabilization algorithm below).
I think the problem is that your expression is false after the first digest.
undefined === 'bar' is false.
Maybe something like
<div ng-if="::(myObject.foo ? myObject.foo === 'bar' : undefined)"></div>
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