Skip to content

Instantly share code, notes, and snippets.

@Gamblt
Created January 28, 2016 13:37
Show Gist options
  • Select an option

  • Save Gamblt/5a0fcbe35db960b4b953 to your computer and use it in GitHub Desktop.

Select an option

Save Gamblt/5a0fcbe35db960b4b953 to your computer and use it in GitHub Desktop.
//Use timeout to ignore changes events while object initialization.
setTimeout(function() {
var keys = Object.keys($scope.news);
console.log('Keys [%o]', keys);
for(var key in keys){
console.log('Watch property [%s]', keys[key]);
var f = function(property) {
console.log('Property [%o]', property);
$scope.$watch("news."+property,
function (value) {
console.log('Change property [%s] {%s}', property, value);
}, true);
}(keys[key]);
}
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment