Clarification about lazy one-time binding for object literals #7663
Description
Hi,
migrating from bindonce to the new one-time bindings, I cannot do something like: ng-style="::{color : colorVar}"
where colorVar is not initially set.
http://plnkr.co/edit/hR1tbyO4E7wEdUG4C2vf?p=preview
In this plunker, setting colorVar is delayed by 1500 ms, and the one time binding does not apply the change. It works for name, though.
Reading the code, it looks like this is because the one time wrapper for $parse checks if the whole expression is undefined, so the ng-style expression is intially defined as {'background-color': undefined}
, which is 'good enough' for one time bind. The workaround that comes to mind is putting the whole ng-style expression in a variable and set that after the timeout. (see plunker) However, that is more verbose and you lose the "expressiveness" of the template.
Is this expected use, or can this be changed in the future? It sure is confusing at least!