-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(Attributes): added support for attributes observing deregistration #5609
Conversation
In order to make the behavior compatible with $rootScope.$watch and $rootScope.$on methods, and make it possible to deregister an attribute observer, Attributes.$observe method now returns a deregistration function instead of the observer itself. BREAKING CHANGE: calling attr.$observe no longer returns the observer function, but a deregistration function instead. To migrate the code follow the example below: Before: directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = attr.$observe('someAttr', function(value) { console.log(value); }); } }; }); After: directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = function(value) { console.log(value); }; attr.$observe('someAttr', observer); } }; });
I'm sorry, but I wasn't able to verify your 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 me 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. |
otherwise this looks good to me, but since it requires a breaking change I'm going to triage it for 1.3 |
Hi Igor. Just signed it again, but I think I have some problem with the CLA signature, as you can see in this PR. Can you help me with this CLA signature? I'll try mailing it anyway. |
+1 |
+1 Yeah the old behavior makes 0 sense to me. |
+1 |
1 similar comment
👍 |
the problem is that you signed CLA with |
In order to make the behavior compatible with $rootScope.$watch and $rootScope.$on methods, and make it possible to deregister an attribute observer, Attributes.$observe method now returns a deregistration function instead of the observer itself. BREAKING CHANGE: calling attr.$observe no longer returns the observer function, but a deregistration function instead. To migrate the code follow the example below: Before: directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = attr.$observe('someAttr', function(value) { console.log(value); }); } }; }); After: directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = function(value) { console.log(value); }; attr.$observe('someAttr', observer); } }; }); Closes angular#5609
I merged this one, but please update your commit email signature or sign CLA with the other email. |
Thank you @IgorMinar Yes, I've signed with both e-mails. The last time I did with |
In order to make the behavior compatible with $rootScope.$watch() and $rootScope.$on methods, and
make it possible to deregister an attribute observer, Attributes.$observe method now returns a
deregistration function instead of the observer itself.
BREAKING CHANGE: calling attr.$observe no longer returns the observer function, but a
deregistration function instead.