Angular $watch | returning the item from function

angularjs, javascript

Solution

This works:

$scope.$watch("someData", function( value ) {
   console.log( value );
});

Problem

I'm interested to find out why i always have to do this ``` $scope.$watch( function() { return $scope.someData; }, function( value ) { console.log( value ); }); ``` for angular to actually watch the data, why do I have to do this, this is one of the things that really bug me because it looks pointless. If I do something like this ``` $scope.$watch($scope.someData, function( value ) { console.log( value ); }); ``` Which is nicer, it never works? I also use this a lot with factories say that `$data` is a factory I have to do ``` $scope.$watch( function() { return $data.someData; }, function( value ) { console.log( value ); }); ```

Original source