Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created August 14, 2014 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayamflow/ee453481d31713d0b10c to your computer and use it in GitHub Desktop.
Save ayamflow/ee453481d31713d0b10c to your computer and use it in GitHub Desktop.
Angular $watch tricks

#Angular.js $watch tricks

###Angular enables you to $watch anything:

  • $scope.foo
$scope.$watch('foo', cb);
  • var foo
$scope.getFoo = function() { return foo; }
$scope.$watch('getFoo', cb);
  • multiple values
$scope.foo, $scope.bar
$scope.$watch('[foo, bar]', cb);
// or
$scope.$watch('{some: foo, thing: bar}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment