Skip to content

Instantly share code, notes, and snippets.

@jbmilgrom
Last active May 22, 2016 15:57
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 jbmilgrom/2edc4071c01f70b32a81 to your computer and use it in GitHub Desktop.
Save jbmilgrom/2edc4071c01f70b32a81 to your computer and use it in GitHub Desktop.
scope.$watch('obj1', function callback(newValue) {
console.log('obj1: ', newValue);
});
// (when initialized) prints out: undefined
$timeout(function() {
scope.obj1 = {name: 'jonathan'}; // prints out: {name: 'jonathan'}
});
$timeout(function() {
scope.obj1.name = 'michael'; // no "change" registered, no print out
}, 500);
$timeout(function() {
scope.obj1.age = 30; // no "change" registered, no print out
}, 1000);
$timeout(function() {
// it's a new object!
scope.obj1 = {name: 'jonathan'}; // prints out: {name: 'jonathan'}
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment