Skip to content

Instantly share code, notes, and snippets.

@jbmilgrom
Last active May 20, 2016 12:27
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/036624776381158b98c4493014c2217d to your computer and use it in GitHub Desktop.
Save jbmilgrom/036624776381158b98c4493014c2217d to your computer and use it in GitHub Desktop.
$scope.firstTeam = [{
first: 'steph',
last: 'curry'
}, {
first: 'lebron',
last: 'james'
}];
$scope.$watchCollection('firstTeam', function(firstTeamArray) {
console.log("change to the first team! ", JSON.stringify(firstTeamArray));
});
$timeout(function() {
$scope.firstTeam.push({first: 'russel', last: 'westbrook'});
}); // new member, print!
$timeout(function() {
$scope.firstTeam.sort(function(player1, player2) {
if (player1.first < player2.first) return -1;
});
}, 300); // reordering, print!
$timeout(function() {
$scope.firstTeam[0].height = 75;
}, 600); // member mutation, no print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment