This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite right.
::(text | someFilter)
is actually the same as::text | someFilter
.We consider an expression to be one-time binded when the first two non-whitespace characters are "::", regardless of what follows.
The first half of the added diff is correct though and worth elaborating in the doc (the avoid re-filtering part).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, at least for the tests that I did using 1.3.0-beta18, the two versions behaved differently in the way I have described it. More precisely, the two expressions that I have tested were
{{ ::'myString' | myFilter }}
and{{ ::('myString' | myFilter) }}
wheremyFilter
is a filter that we have developed, which is closed source and therefore I cannot release its source here. To say little more about the filter, it's quasi an asynchronous filter that depends on a service that in turn needs to fetch a resource asynchronously first in order to be able to work meaningfully. The filter returnsundefined
unless it is ready and irrespective of the input. So, while{{ ::'myString' | myFilter }}
got stable immediately (seemingly because of the constant string expression) and in our case always before the filter was ready (i.e., while it was still returningundefined
), the other version{{ ::('myString' | myFilter) }}
got stable always after the filter was ready.I haven't further analyzed Angular's source code, but it seems that this is a feature implied by the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being familiar with Angular's source code, I can assure you that both are evaluated the same by the expressions parser. If they're behaving differently in your app, it's probably something unrelated that's causing that.
Here's a plnkr trying to replicate what you describe, a constant value passed to an asynchronous filter with one-time binding in the expression: http://plnkr.co/edit/mHmuSTu0KR95YZHzZ5Lf?p=preview
If I missed anything, please let me know. If you can link to a plnkr that reproduces your scenario, that would be great.
Again, I believe the first part of the doc changes are worth adding, and maybe even elaborating on