Skip to content

Instantly share code, notes, and snippets.

@Donmclean
Created September 20, 2015 16:24
Show Gist options
  • Save Donmclean/a3d0a21a4d93b889c314 to your computer and use it in GitHub Desktop.
Save Donmclean/a3d0a21a4d93b889c314 to your computer and use it in GitHub Desktop.
Using Angular Watch Function
function MyController($scope) {
$scope.myVar = 1;
$scope.$watch('myVar', function() {
alert('hey, myVar has changed!');
});
$scope.buttonClicked = function() {
$scope.myVar = 2; // This will trigger $watch expression to kick in
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment