This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($rootScope): Set no context when calling helper functions for $watch
When calling a $watch getter or listener, do not expose the inner workings with `this`. Closes: #13909
- Loading branch information
Showing
2 changed files
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1c6edd4
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.
Sadly this was removed, now how i can get the watchExpression this.exp inside listener function?
1c6edd4
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.
@guziakas would it be possible to know what the use case for this is?
1c6edd4
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.
I have written directive where you can specify filter in attribute, you provide a list of fields to watch and react on value changes,
code sample:
1c6edd4
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.
@guziakas why not
We were exposing the inner-workings on how
watch
works, and this is not part of the public API. Sorry, but the context will not be restored.1c6edd4
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.
That approach works perfectly! Thanks for good and simple solution :)
1c6edd4
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.
I've written a
<chart>
'ing C3/D3 wrapper directive that dynamically instantiates chart-type implementations based on a chart's options. Thanks to this fix I can dovar ChartImpl = this[type.charAt(0).toUpperCase() + type.substr(1) + "ChartImpl"]; var chart = new ChartImpl(data, options);
.My implementation is not backwards compatible to prior releases of Angular because of the screwed up
this
context in those releases.Please ensure that
this
here and elsewhere remains the global context so we can utilize the full power of non-strict JavaScript! Thanks!