Closed w-sz closed 8 years ago
Yes translate-values are supported but they must be resolved as this library only binds once.
You can use an ng-if
to keep the element from compiling until all the data is ready
@ajwhite but is not better to observe attribute and when is value there - stop ? Ng-if looks like little bit hack. Right now you fill up it immediately, but translate-values="{value}" can come later.
To the contrary, I find that observation defeats the purpose of one time binding.
null
, or undefined
? We have to make assumptions for areas that we know nothing about.I feel pretty strong about enforcing single-use behavior on this directive. When situations like this come up, I feel that the implementation in how this tool is used needs to be evaluated. The question I usually ask myself is "If this translation depends on a value, and that value does not yet exist, why am I trying to present this translation?"
I agree with your point of view, but:
In my opinion is much more secure to observe element, because in this moment weak connection can make field empty.
Let's look at this this another way.
Say you were to take one of these values that doesn't resolve until a later point in time.
You'd likely want to avoid one time binding it, as the initial empty value will never reevaluate
{{ ::valueLoadingLater }}
You would bind it regularly
{{ valueLoadingLater }}
I'd suggest you use the regular translate
directive for values that should not undergo one time binding.
To your points:
false
, and when it comes back when true
, the directives will go through their link
phase.undefined
or null
. We cannot know this for sure, as we are only a library.I'm sorry that this does not support observation, as this is meant to only bind once. I'd suggest a few things for you moving forward:
translate
ng-if
to exclude content that depends on data that does not exist yet@ajwhite ng-if will set-up watcher on element, then what is the point to translate it once?
You are just ignorant - no more and because of that you will never by good.
Do you support translate-values, when is fill up after initialize with some server call ?
I don't see any $observe in code. You can add this and kill watcher after when value is there.
http://stackoverflow.com/questions/20926503/how-to-stop-observe-in-angularjs