-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
Please, update the section on one-time bindings by another example showing how the feature can be used with filter (chains). I was very surprised - positively - when I discovered that feature today and wished I could have read something about it before, which would have saved me some time.
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
<div>{{::(text | someFilter)}}</div> | ||
``` | ||
|
||
Observe that `::(text | someFilter)` is not the same as `::text | someFilter`. The |
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) }}
where myFilter
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 returns undefined
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 returning undefined
), 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
CLA signature verified! Thank you! Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes). |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
@rodyhaddad is correct --- see Lines 1047 to 1050 in c90ad96
@twwwt were you planning on updating this? |
Please, update the section on one-time bindings by another example showing how the feature can be used with filter (chains). I was very surprised - positively - when I discovered that feature today and wished I could have read something about it before, which would have saved me some time.