angular/angular.js — pull request #5609 by caiotoon (2014-01-03 04:28:13+00:00)
Title: feat(Attributes): added support for attributes observing deregistration

In order to make the behavior compatible with [$rootScope.$watch()](http://docs.angularjs.org/api/ng.$rootScope.Scope#methods_$watch) and [$rootScope.$on](http://docs.angularjs.org/api/ng.$rootScope.Scope#methods_$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);
}
};
});